Announcement Announcement Module
No announcement yet.
Send message from Itemprocessor to jms using Spring integration Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Send message from Itemprocessor to jms using Spring integration

    Is there any pattern or options to send message from spring batch itemprocessor to JMS using spring integration?

  • #2
    The following applies to any java application, not just an ItemProcessor.

    Simply define an messaging gateway interface (see the section 'Messaging Gateways' in the reference manual).

    Define your flow...


    inject the gateway into your ItemProcessor and invoke it.

    (This assumes a void return and one-way).

    If you need to wait for a response from JMS then replace the outbound adapter with an outbound-gateway and put a return type on your gateway interface method.

    This allows you to isolate your application from the infrastructure - you can replace the outbound adapter with other technology (e.g. AMQP) with no changes to your ItemProcessor.

    Also, in your JUnits, you can replace the adapter with something else, like a logging-channel-adapter, for example.


    • #3
      Hi Gary,

      Thanks for your detailed reply. One more question like in Mule - VM inbound/outbound is there anything similar in Spring Integration. I am really new to Spring Integration.



      • #4
        In Spring Integration, endpoints are connected by channels, which are themselves first-class-citizens and entirely configurable.

        Extending the previous example, you might have


        A service activator is an endpoint that invokes some arbitrary code, often a POJO. If you are not familiar with this vocabulary, see

        In this way, the clent that invokes the gateway, and the service invoked by the service-activator do not have to know they are running in a messaging environment.

        Now, because channels, are first class citizens in SI, you can configure what type of channel you want. By default, it will be a direct channel, in which case the service is invoked directly on the calling thread. Or, you can configure it as a jms-backed chanel, to achieve persistence, and the service will be invoked asynchronously. There are other options for channel persistence too (e.g. JDBC message store).



        • #5
          Thanks Gary,