It should not be too difficult to do this. It should be one extra class really. You can take look at one of the existing gateways (i.e JMS). If you're interested we can start discussing implementation details on this thread. Next week should be a good week to start that. We always love to have contributors!
I browsed a little bit through the sources. First I was a little bit confused because I looked at the implementation of JMSCourier. There is a lot of configuration hardcoded in TwoWayCourierImpl and the XSD parsing looks frightening.
But for adding a gateway I just have to implement one class, e.g. CICSGatewayListener, and I have to add a gateway configuration in XML which points to that class. All the XML parsing is done by JBoss ESB and I do not have to cope with the Courier-classes because they are only for internal, ESB-aware messages.
Is this right?
I checked the JMSGatewayListener again and could find no code for sending a JMS message only for receiving. This makes sense for a listener, but does this mean that I have to create also a CICSCourier for sending messages?
I think what you're after is a reverse gateway?
Maybe, I am not sure :-)
I thought a gateway is bidirectional.
It can receive messages from the external system, adapt it to the internal ESB format, and delegate it to the configured action/service. But it is also capable of accepting internal messages from the ESB and forward them to the external system.
Is this assumption wrong?
If so, do I need to add some kind of "sender service" that sends messages to a CICS host and use a gateway only for receiving messages?
Let's see if we can clarify.
Currently, gateways are inbound only. They are supposed to obtain any object (file, JMS message, etc.), package it as an ESB message, and send it to an EPR where a 'message aware listener' will pick it up, and pass it to an ActionProcessingPipeline.
Once you are in the pipeline, any outgoing arbitrary object (arbitrary in the sense that it does not need to be an esb message), can be produced in any (user) action class, either by the method speficied in the 'process' attribute (default is process(Message) method), or in the method specified in the (optional) 'okMethod ' property for normal completion, or in the method specified in the (also optional) 'exceptionMethod' property
A generic example of how to do this is:
<actions> <action name="outboundObject" class="mypackage.MyClass" process="step1, step2,step3"> <property name="okMethod" value="mySuccessMethod" /> <property name="exceptionMethod" value="myFailureMethod" /> </action> </actions>
This example has only one action class in the pipeline, but it invokes three methods in sequence: step1, step2 and step3. Signature of these three is Message stepX(Message) throws Exception
If the 'process' attribute were not included, the default is to invoke the Message process(Message) method in the action class.
If at any point, the sequence of steps throws an Exception, and the property with name 'exceptionMethod' was specified (as in our example), then the corresponding method will be invoked (signature: void xxxxx(Message, Throwable))
If the sequence runs successfully (no Exceptions thrown), and the property with name 'okMethod' was specified (as in our example), then the corresponding method will be invoked (signature void zzzzz(Message))
An 'outbound gateway' can be implemented simply by implementing methods for success and failure with the proper signatures, and specify them in the 'okMethod' and 'exceptionMethod' properties of the action class.
I hope this helps.
Thanks a lot for your explanation. I think I understand the architecture now. We will start to implement a small sample application and if there are any problems or successes I will post them.
Thanks Torsten. If you come up with anything that you think would be of wider use to the JBossESB community and want to contribute it back, let us know.