Announcement Announcement Module
Collapse
No announcement yet.
Usage of Spring Integration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Usage of Spring Integration

    Hi,

    I need help to verify the usage of SI for the following scenario:

    I have a service component (interface), whose implementation consists of several sub components like endpoints, routers, and transformers. Some of these endpoints are finite state machines. Incoming messages (e.g. sent by a client via HTTP) will trigger some transitions within the state machine and may (or not) produce new events/messages which will be routed to other state machines or can be polled from a client (e.g. via HTTP GET). With other words: A client may send events to the service component (HTTP PUT) and can ask for events (HTTP GET), asynchronously. Because of a state machine holds its state, I need several instances of the service. And this is the conflict that I see. In SI all components including channels are stateless.
    Does this mean that I canít use SI for that scenario?

    ~Thomas

  • #2
    Hmm, i'd say it is a perfect use case for Spring Integration and i think you would realize it very quickly if you try to wire something like this.
    In fact if you have a moere concrete use case, lets see if we can help you get it done and possibly turn it into a nice sample.

    Comment


    • #3
      Hi Oleg,

      Let me try to describe my use case more in detail (I made some simplifications).
      1. HTTP client sends an init request (HTTP PUT) to server (URI parameters: instance id, payload: xml)
      2. server creates new state machine, dispatches the event (xml payload) to the state machine and maps the state machine to the transmitted instance id
      3. HTTP request returns with status code 204 (No Content)
      4. state machine enters a state and sends two events via callback function (events must be stored for further processing)
      5. HTTP client sends HTTP GET request to server (URI parameters: instance Id, response: first event from buffer (serialized to xml)
      6. HTTP client sends another HTTP GET request to server and gets the second event from buffer
      7. HTTP client sends further HTTP PUT requests to the server which may trigger transitions in the state machine, and so on

      Now, there can be multiple HTTP clients sending requests with different instance id's to the server in parallel.
      Each instance id must be mapped to its own state machine.

      ~Thomas

      Comment


      • #4
        Well, from the SI perspective it is actually very easy. One client posts something with some identifier or no identifier and another client polls by id or the next available resource.

        With regard to maintaining the state, there is a lot you can do with Spring custom scoping, but I would assume that once you introduce the state you want to preserve the state between AC restarts (normal or due to system crashes) so you might want to introduce some persistent store for your state.

        Was your question really about using SI for managing the state or you have some state machine in mind?

        Comment


        • #5
          I'm using the state machine implementation from apache commons (http://commons.apache.org/scxml/).
          The state will be managed by the instance of the state machine.

          Comment


          • #6
            Hi Oleg,

            I'll take a look at custom scoping.
            Assuming it can be solved, the state machine will call a callback function for new events. These events should be send to a channel for further processing (transfoming. routing, etc.). After that the HTTP client should poll for these events. How can I realize this?

            ~Thomas

            Comment


            • #7
              It seems that scoping doesn't work well with SI. I've configured a bean for an inbound channel adapter with scope="session". If you have more than one thread running in your pipe (e.g. if you are using a queue channel), then scoping doesn't work. That is because scoped beans are stored in a thread-local variable.
              Can anyone confirm this?

              Comment


              • #8
                Thomas

                Could you please post your config so i can better understand what you are trying to accomplish?

                Comment


                • #9
                  Oleg,

                  here is my simplified configuration:
                  Code:
                  <?xml version="1.0" encoding="UTF-8"?>
                  <beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xmlns:aop="http://www.springframework.org/schema/aop"
                      xmlns:int="http://www.springframework.org/schema/integration"
                      xmlns:int-http="http://www.springframework.org/schema/integration/http"
                      xsi:schemaLocation="
                              http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                              http://www.springframework.org/schema/aop http://www.springframework.org/schema/task/spring-task-3.0.xsd
                              http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd
                              http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http-2.0.xsd">
                  
                      <beans:bean id="guiHandler" class="com.tsystems.test.GuiHandler" scope="session">
                          <aop:scoped-proxy proxy-target-class="false" />
                      </beans:bean>
                      
                      <int:channel id="gui">
                          <int:queue/>
                      </int:channel>
                  
                      <int-http:inbound-channel-adapter id="guiInboundAdatper" channel="gui" />
                      
                      <int:outbound-channel-adapter channel="gui" ref="guiHandler" method="handleInput">
                          <int:poller fixed-delay="1000" />
                      </int:outbound-channel-adapter>
                  
                  </beans:beans>

                  Comment


                  • #10
                    Thomas

                    I didn't forget about you, just struggling to find tie to really look into it in more details. My main point though is that i ned to understand your use case for state management, because in the Messaging system state is typically maintained within the Message while the flow stays stateless. So the real question is how to enrich new Messsage with an existing state and how to know when the Message is the initial Message and therefore would be a part of the new state. This means that something has to come as part of the Message and you can have some custom endpoint (content enricher) which will be at the top of the flow enriching the Message with a state. Once the Message contains the state all downstream components (filters, routers etc) can act based on the state info.

                    I'll also forward this thread to Josh Long who has experience with Activity BPM and he'll provide you with a bit more input.
                    Once i get more time i'll address it as well

                    Comment

                    Working...
                    X