Announcement Announcement Module
Collapse
No announcement yet.
Channel/Message Persistence, Custom Channel.... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Channel/Message Persistence, Custom Channel....

    Hi

    These are the observations that I ran into when I tried to implement the functionalities of the thread "Spring Integration for ESB"

    Please read on

    Following was noticed with SI-M4

    I did the following to create customized channels:

    They are very simple (No error handling etc).
    It just writes the incoming messages into a folder in a predetermined directory, upon a doSend() method.
    It just reads the files (to get messages) from the folder in a predetermined directory, upon a doReceive() method.
    Implemented the purge() and clear methods() of the super interface.
    Please see the code in the package com/example for CustomChannel.java and CustomChannelFactory.java

    I wanted to use my above CustomChannel in the 'quote' demo, so I did the following:

    As per the reference documentation, I did the following changes to the configuration file

    Issue no. 1:
    Changed the
    <message-bus/>
    to
    <message-bus channel-factory="customChannelFactory" />
    <beans:bean id="customChannelFactory" class="com.example.CustomChannelFactory" />
    I made the Quote class Serializable.
    According to the documentation this should create and register the custom channels but it didnt.
    The message bus still created and registered SimpleQueueChannel.

    However,I unregistered the SimpleQueueChannel and created a new CustomChannel and registered it with
    the same name("quotes") this made the Publisher publish messages into the CustomChannel (I could
    see the files being created in the folder) and the Subscriber reads the messages
    (from the queue/Channel--- I'm not sure about this)

    Issue no. 2:
    If you see the code of the com.example.CustomChannel.java,
    doReceive() deletes the file created in the doSend() method.
    I believe that the Messages are read from the channel only by a doReceive().
    However in the sample code the messages/files are not deleted from the folder.

    Is this a mistake in the CustomChannel.java (Does it not handle threads
    properly? I think the use of a Semaphore would solve the problem, but please correct me
    if I am wrong).
    Or
    is it that SI is passing the messages from the memory instead of doReceive() from the channels ?

    Issue No. 3: Persistence (No serialVersionUID in the Serializable classes).
    My intention of this custom channel is to persist messages from one application.
    Read them in another application!

    This was not possible because GenericMessage, MessageHeader Classes dont have a
    serialVersionUID variable defined in them, hence I had to create one CustomMessage
    and over-ride the default MessageHeader with the modified one I have.

    The modified Quote sample is divided into two applications

    1.) Pub-Integration:
    Persists ticker messages in the Custom-Channel folder.

    2.) Sub-Integration:
    Reads the ticker messages from Pub-Integration in the same Custom-Channel folder.
    To make Subscriber work, I create a dummy publisher publish default ticker messages
    which I dont intend to read in the Subscriber, but I am interested in the other ticker
    messages from the Pub-Integration.

    However as I suspect in the Issue No: 2, The Subscriber can read only messages
    Published from Publisher in the same JVM.

    Please reply with advices on how to make the CustomChannel.java work with the
    above scenario.

    Or is it not the way to use SI ?

  • #2
    Great stuff thanks. I'll free up some time to look at the code later this week (if nobody beats me to it )

    Comment


    • #3
      Hi

      Can you please post the whole configuration file for registering a custom channel factory?

      For now, this produces the expected result:

      Code:
      <message-bus channel-factory="stubChannelFactory"/>
      
      <beans:bean id="stubChannelFactory" 
          class="org.springframework.integration.channel.factory.StubChannelFactory"/>
      
      <channel id="defaultChannel"/>
      i.e. the resulting defaultChannel is an instance of StubChannel.

      (this is tested in org.springframework.integration.channel.config.Def aultChannelParserTests,
      recently added to the trunk)?

      Thanks,
      Marius

      Comment


      • #4
        Hi Marius and Iwein

        Thanks for your help.

        I just was swapping workspaces from 2 pcs, my work and office pc.

        I had mixed up SI-M3 and SI-M4. Now when I used SI-M4 libs for both the apps
        it seemed to work.

        Though there is the issue of Persistence stands (serialVersionUID)

        To make it work better I have to improve the CustomChannel

        Will try to work on it to connect apps in 2 different JVMs and Platforms.

        Thanks for your help.

        Regards
        Bharath.

        Comment


        • #5
          Bharath,

          From what I can see, you need to pass on the message content from one application to the other. In this case, using a SourceEndpoint and a TargetEnpoint on the appropriate ends would be the way to do it, rather than using a Custom Channel.

          In this case, you can take a look at the file demo sample where we write/read binary files from a given directory. In your case, the serialization/deserialization of the payload objects can be done using a custom MessageCreator and MessageMapper, that would de-serialize and serialize the messages accordingly.

          Regards,
          Marius

          Comment

          Working...
          X