C# String GetHashCode()

It is very difficult to Java developers to write C# code. Not because of the language – they are pretty much the same. But it turns out you make basic assumptions which are just not true.

We develop C# code that access services deployed in WebSphere ESB and send messages in WebSphereMQ. The sender creates a message identifier, that consists of the sender id, object type and more. The listener creates the same identifier, and listens to the queue with this identifier.
Suddenly – the identifier the listener and the sender create is different.
Turns out that the problem lies in the fact that the sender is a 32bit machine, and the listener runs on a 64bit machine.
Why is that a problem? Because in .net, code is not cross platform – not even between Windows environments – since the GetHashCode() function of String is not cross platform – and works differently on 32bit and 64bit machines.
Anyway, we wrote our own Hash function, that simply copies the java.lang.String hash() function (every JDK comes with src.zip, where you can find the java.lang.String code).
3 hours of my life wasted…

WebSphere Process Server – skipping steps in the process

A customer of mine has decided to build an application that can monitor his processes, instead of the regular WPS supplied tool.

His main concern was skipping steps. Turns out that when a process has executed a specific activity, and this activity is in a special position (like user task) – an outside application can cause a skip in the process.
I have developed a short demo for this, and I’m enclosing the main method here. Just make sure to disable the process security before running it – or you’ll get a non authorized exception…
// Connect to the server
Properties props = new Properties();
props.put(Context.PROVIDER_URL, “iiop://localhost:2811”);
javax.naming.InitialContext ctx = new javax.naming.InitialContext(props);
// Lookup the BusinessFlowManager. If you get casting exception – read the InfoCenter – you need to add some JARs to your code – it’s WPS/ProcessChoreographer/client/bpe137650.jar
Object lookupResult = ctx.lookup(“com/ibm/bpe/api/BusinessFlowManagerHome”);
BusinessFlowManagerHome processHome = (BusinessFlowManagerHome) PortableRemoteObject
.narrow(lookupResult, BusinessFlowManagerHome.class);
BusinessFlowManager bfm = processHome.create();
// Replace with any process id
ProcessInstanceData pid = bfm.getProcessInstance(“_PI:90030124.f71386d4.dbed54f5.5d84025c”);
// Replace with any activity name
ActivityInstanceData aid = bfm.getActivityInstance(pid.getID(),”Wait”);

// Skip to the specific activity
bfm.skipAndJump(aid.getID(), “TargetActivity”);