Samba file transfer in IIB v9 with Java custom nodes

Samba file transfer in IIB v9 with Java custom nodes

We had to implement a Samba file transfer using IBM Integration Bus. Because my customer decided not to mount the shared Samba folder on the machines, we couldn’t use the default File Read and File Write nodes of IBM Integration Bus. Therefore I had to write custom nodes in Java, so they could be used and reused in multiple applications. The use of IBM’s MQFTE solution is maybe a future evolution.

Trigger

Before going into further details of these nodes and its use, another thing has to be explained. There exists a dynamically created .properties file, which contains the following information about multiple Samba directories (each time for the source and destination):

  • Credentials (domain, user & password)
  • IP address
  • Directory location
  • Pattern of the requested filenames

A message flow reads this .properties file every 60 seconds. I’ve wrote some Java code in this message flow, which creates a command message for every directory listed in the .properties file. All of these command message are then sent separately to another message flow that contains the Samba poll node.

Custom Samba nodes in Java

I separated this Samba file transfer in 3 nodes:

  • Samba poll: receives a command from the trigger and polls that certain directory. For each file it finds, which satisfies the pattern, it sends a command with information about the source file and its source location and destination.
  • Samba file read: receives a command from the Samba poll node and actually reads the file and sends it binary in a command message with information about its destination.
  • Samba file write: at last the Samba file write node receives the last command, containing the file binary. It writes the file to its required destination.

These nodes are not all in the same message flow and WebSphere MQ is to put the command messages on queues in between the message flows. The poll node is always in a separated message flow so it can poll all the directories fast without having to wait for files to be read or written. This flow and the Trigger flow are both out of transaction, since their command messages will be resent after the next trigger in 60 seconds if a failure occurs and they don’t hold sensitive data.

The read and write node are only in the same message flow if the file transfer has to be done locally. If the file has to be written remotely to a different machine, it will be put on a remote queue first which will arrive at the destination machine using channels.

Overview with example

The following image provides the example of the complete operation of the nodes to give a better overview. In this example I pretended there are 2 different directories listed in the .properties file. The first directory and its files are shown in blue and the second in red. This will give you a better idea of multiple messages in multiple directories.

Samba operation flow

Author: Lowie Cuypers

No Comments

Post A Comment