1 2 Previous Next 20 Replies Latest reply on Sep 7, 2007 5:26 AM by Tom Fennelly

    How to define a new custom provider?

    Mihai Anescu Newbie

      Hello,

      We need to define a new type of provider.

      I read the guide and I saw that one way to do it is to define like this:

      <provider name="JBossMQ">
       <property name="connection-factory" value="ConnectionFactory" />
       <property name="jndi-URL" value="jnp://localhost:1099" />
       <property name="protocol" value="jms" />
       <property name="jndi-pkg-prefix" value="com.xyz" />
      
       <bus busid="local-jms">
       <property name="destination-type" value="topic" />
       <property name="destination-name" value="queue/B" />
       <property name="message-selector" value="service='Reconciliation'" />
       </bus>
      </provider>


      However, I don't see exactly how do I define a brand new provider with my custom classes??? Can anyone provide an actual live example of a new provider & gateway type (not JMS, SQL, FS, FTP)?

      I mean, I know i need one listener which has to have a specific constructor and one method to process the message, but I also need a gateway that can send to tha listener some specifi objects, correct? Sow how do I define a custom gateway/listener? Is there a quickstart that shows such a thing?

        • 1. Re: How to define a new custom provider?
          Mark Little Master

          I may be wrong, but I think what you need is covered here, or would be if that task was finished. Unfortunately it hasn't had priority over other tasks.

          • 2. Re: How to define a new custom provider?
            Mihai Anescu Newbie

            Yes, it seem to be still in progress.

            But maybe somebody else has dealt with this kind of situation and can provide some help?

            We will need to integrate more than one custom provider/gateway so we really need to start doing this work.

            The developer guide is quite cryptc in what it says, I looked in the XSD but I can't figure out how to do it. I know how to define a custom composer for a listener of a specific type, we even used a custom composer for a JMS listener, but the rest is still unknown...

            • 3. Re: How to define a new custom provider?
              Mark Little Master

              Well if you want to give it a go, we'll try to help here. The result could feed into that task too.

              • 4. Re: How to define a new custom provider?
                Mihai Anescu Newbie

                I am trying.

                Now I'm digging through you're code, I have found (I think) the attributes needed to define a custom listener (AbstractFileGateway, UntypedListenerrMapper, etc). So now I'm changing my code.

                So far I don't know where to look to find what I need for the tag. Maybe you can give some pointers?

                • 5. Re: How to define a new custom provider?
                  Burr Sutter Master

                  Is your custom provider "event-oriented" or "polling-oriented"?

                  If you are polling oriented check out the new quickstart (available in 4.2.GA) called scheduled_services. It can be used as a template for any polling based "gateway".

                  If you want "event-oriented' then you should review the section in the Programmer's Guide related to JCA gateway. This is very you bring your own JCA adapter (or build your own) that allows it to emit events as messages into the ESB.

                  Burr

                  • 6. Re: How to define a new custom provider?
                    Tom Fennelly Master

                    The following might help you...

                    1. GeneratorUnitTest.java has one test that tests for equivalence between a config specified using the specialised bus-provider types and and what should be an equivalent config using the base bus-provider type. Look for the "test_generate_files()" test. It basically checks that jbossesb_config_01.xml and jbossesb_config_02.xml are the same thing.

                    2. If it's a schedule based provider you're interested in (e.g. like the file/ftp gateways polling for file drops), you could look at the <scheduled-listener>. It allows you to specify an "event-processor" class, which can effectively become your gateway imlementation. See the "Scheduling of Services" section in the programmers guide.

                    • 7. Re: How to define a new custom provider?
                      Mihai Anescu Newbie

                      It is polling oriented (or scheduled).

                      @tfenelly
                      So I will try the scheduled-listener, I guess.

                      I have the 4.0M3 release which apparently doens't contain the part you mention. Where can I find this section? Will this be available in the 4.2GA? Or can I already find it in SVN?

                      • 8. Re: How to define a new custom provider?
                        Tom Fennelly Master

                        It's in 4.2GA, which has just been released. Have a read of that section of the programmers guide and make sure it's a fit.

                        • 9. Re: How to define a new custom provider?
                          Kevin Conner Master

                          Yes, it is up on the labs page now. I have just finished checking the links :)

                          • 10. Re: How to define a new custom provider?
                            Mihai Anescu Newbie

                            Guys,

                            I just tried the scheduled_services sample.

                            Tried to run 'ant deploy-jms-dests' (as mentioned in the readme.txt)
                            And it crashes with this:

                            deploy-messaging:
                             [copy] Warning: Could not find file C:\jbossesb-4.2GA\samples\
                            quickstarts\scheduled_services\jbm-queue-service.xml to copy.


                            I downloaded both the bin and src, I looked in both, neither contains the mentioned file.

                            I don't even think it's required, I used the 'ant run' and it appears to work.

                            • 11. Re: How to define a new custom provider?
                              Tom Fennelly Master

                              OK, sorry about that. Just skip that step for this particular quickstart - JMS is not relevant.

                              • 12. Re: How to define a new custom provider?
                                Mihai Anescu Newbie

                                Hello,

                                great guys, I made the scheduled-provider work.

                                First I'll present the "gateway" we have, after that I'll put a question.

                                We have 2 WebServices. The first WS will return an ArrayList of messages IDs (I send an int parameter that says the maximum number of IDs to return). So I'll basically get either an empty object, or n IDs stored in that ArrayList.

                                The second WS is used to process one of the messages, based on its ID.
                                So in my first client app (used to test that it works, before integrating into ESB), I made something like this:

                                int n = 100;
                                while(true)
                                {
                                 Thread.sleep(5000);
                                 ArrayList<String> messageIdsList = receiverListWSHandler.getReceivedMessagesIds( n );
                                 for (String messageId : messageIdsList) {
                                 WSMessage msg = receiverWSHandler.downloadMessage(messageId);
                                 //code to transform it into an ESB message
                                 }
                                }
                                


                                So now the questions:
                                From what I've seen in the scheduler, the composer class will create exactly one ESB message. Is that correct? Or I can still generate "n" ESB messages by runnign once the scheduler?

                                I mean, my code looks like this now:
                                int n = 1;
                                 ArrayList<String> messageIdsList = receiverListWSHandler.getReceivedMessagesIds( n );
                                 if (messageIdsList != null && messageIdsList.size() == 1) {
                                 String messageId = messageIdsList.get(0);
                                 WSMessage msg = receiverWSHandler.downloadMessage(messageId);
                                 //code to transform it into an ESB message
                                 return process(message);
                                 } else {
                                 sysLog.debug("#no message retrieved...");
                                 }
                                 return null;
                                }
                                




                                • 13. Re: How to define a new custom provider?
                                  Tom Fennelly Master

                                  Yeah, if you implement org.jboss.soa.esb.listeners.ScheduledEventMessageComposer, the composeMessage method can only compose a single message what gets pumped into the connected action-processing pipeline.

                                  I remember when doing this I thought of allowing composeMessage return an array of message, but decided against is simply because it would encourage patterns that get messy to manage from a lifecycle perspective - specifically stopping schedule-listener while it's in the middle of processing a big batch of messages. I hoped the speed of processing could be throttled by the frequency of the schedule itself. I suppose we could modify the schedule-listener to loop calling composeMessage untill it gets a null, but I'm not sure I like the idea of that either.

                                  If you implement org.jboss.soa.esb.schedule.ScheduledEventListener your scheduled "work" gets executed in the "onSchedule" method, in which case there's no ESB Message returned or supplied to an action processing pipeline - you just do the whole thing in the org.jboss.soa.esb.schedule.ScheduledEventListener implementation.

                                  • 14. Re: How to define a new custom provider?
                                    Burr Sutter Master

                                    Tom/Team,

                                    How about if he created a service manage the schedule but another service to perform the actual processing on a message by message basis? Essentially the message composer attaches the arraylist to the message object. The first action in the scheduled service action chain loops through the arraylist and use the ServiceInvoker to queue those messages up for the actual processing service.

                                    What do you think?

                                    Burr

                                    1 2 Previous Next