1 2 Previous Next 25 Replies Latest reply on Mar 31, 2009 3:22 PM by Clebert Suconic

    JBM 2.0 examples

    Tim Fox Master

      As a starting point for JBM 2.0 I suggest we ship with at least these examples:

      Can anyone think of any more?

      I believe each example should be in its own directory with its own build script.

      We can create a standard format for the build.xml.

      There should also be a readme.html in the directory explaining what it does and how to run it.

      it should be as simple as typing "ant" to run it:


      Examples
      ------------

      JMS examples

      1) Basic queue send/consume

      2) Basic topic send/consume

      3) Simple transactional example. Transactional send and consume

      4) Durable subscription example

      5) Temporary queue/topic example

      6) Request/response (replyto) example

      7) Selectors on topic example

      8) QueueRequestor example

      9) Clustered queue example

      10) Clustered topic example

      11) Failover example


      Core examples
      ------------------

      1) HTTP transport example

      2) Servlet transport example

      3) SSL example

      4) Failover example

      5) Reconnect to same node example

      6) Bridge example

      7) Symmetric cluster example

      8) Two node chain cluster example

      9) Chain cluster with mediator example

      10) Divert example

      11) Queue with static selector example

      12) Message grouping example

      13) Message redistribution example

      14) Large message example

      15) Paging example

      16) Request/response example

      17) Security example

      18) Management notifications example

      19) Management messages via connection example

      20) Management via JMX example

      21) Scheduled Message example

      22) producer flow control max rate example

      23) client discovery example

      24) transformer example

      26) Interceptors example

      27) Wildcard routing example

      28) solo queue example

      29) message priority example

      30) file message example

      31) pre-ack example

      32) XA example

      33) Expiry queue example

      34) DLQ example

      35) static wired cluster example

      36) cluster with discovery example

      37) Message counters example

      39) browsing example

      40) send acknowledgements example

      41) heuristic commit/rollback example

      42) kick off client example



      others (that might require JCA/app server)

      1) Servlet transport example

      2) Sending from an EJB example in same tx as db update

      3) MDB example

      4) Setting up JCA adapter example

        • 1. Re: JBM 2.0 examples
          Tim Fox Master

          delayed redelivery example

          • 2. Re: JBM 2.0 examples
            Yong Hao Gao Master

            I'm thinking it would be very convenient for user to load the examples as Eclipse projects and run them from within eclipse. Sometimes I need to start with one of the examples and make some changes in order to verify some issue. If this can be done in Eclipse, I can make the changes (as the java editor provide a lot of visual aids and also instant compilation) and run it many times as I want.

            • 3. Re: JBM 2.0 examples
              Clebert Suconic Master

              +1... I liked the idea.

              "gaohoward" wrote:
              I'm thinking it would be very convenient for user to load the examples as Eclipse projects and run them from within eclipse. Sometimes I need to start with one of the examples and make some changes in order to verify some issue. If this can be done in Eclipse, I can make the changes (as the java editor provide a lot of visual aids and also instant compilation) and run it many times as I want.


              • 4. Re: JBM 2.0 examples
                Tim Fox Master

                +1

                • 5. Re: JBM 2.0 examples
                  Clebert Suconic Master

                  Another reason for a separate project:

                  "Say, we start adding examples doing things like MDB, Hibernate, WebServices.. or anything we may want to exemplify... We won' t need to bring those dependencies on the main project"

                  • 6. Re: JBM 2.0 examples
                    Andy Taylor Master

                    Ive added a new jms example template into trunk. There should also be a core one butthat isn't complete yet.

                    The jms template. each example should live in its own directory under examples/jms and should have its own build.xml file and src folder. The example itself will extend JMSExample and implement the runExample() method, See QueueExample or TopicExample. The JMSExample class takes care of starting the server (if needed) and deploying any topics/queues etc. If you look under examples/jms/common/config you'll see the config files that are used by the server. These can be modified if needed. The build file doesnthave to do much since all the compile and run scripts are in the base script. You just have to call a couple of ant targets, again see the queue or topic example and you'll see.

                    The core tests should be the same but found under examples/core. The only difference is how we start the server. The CoreExample base class should just programmatically start the server with the correct configuration.

                    Take a look and if any thing needs change or improving feel free to do it or post suggestion here.

                    • 7. Re: JBM 2.0 examples
                      Andy Taylor Master

                      FYI, the examples don't shutdown correctly when the server is started as there are some threads still hanging about. i'll raise a JIRA for this.

                      • 8. Re: JBM 2.0 examples
                        Andy Taylor Master

                        You'll need to run ant jar before running the examples. It some point i'll add some checks to make sure the jars are available

                        • 9. Re: JBM 2.0 examples
                          Clebert Suconic Master

                          Jeff added a wiki with the list:


                          http://www.jboss.org/community/docs/DOC-13460

                          • 10. Re: JBM 2.0 examples
                            Tim Fox Master

                            The examples list needs to be updated since we decided we're going to pretty much concentrate on the JMS examples for now. (I.e. demonstrate functionality by sending/consuming of JMS messages), since that's what most people will use.

                            Then we'll have a parallel hierarchy for core tests. So the distinction core/jms examples is not that relevant.

                            • 11. Re: JBM 2.0 examples
                              Yong Hao Gao Master

                              hi Andy,

                              I think we can move the name resolving to the JMSExample base class:

                               InitialContext initialContext = getContext();
                               Topic topic = (Topic) initialContext.lookup("/topic/exampleTopic");
                               ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("/ConnectionFactory");
                              
                              


                              So that in each example, we only do get...

                              
                              public void runExample()
                              {
                               Topic topic = getTopic("/topic/exampleTopic");
                               ConnectionFactory = getConnectionFactory("/ConnectionFactory");
                               .......
                              




                              • 12. Re: JBM 2.0 examples
                                Yong Hao Gao Master

                                Let me do these examples, they are easy for me to start.

                                # Simple transactional example. Transactional send and consume
                                # Durable subscription example
                                # Temporary queue/topic example
                                # Request/response (replyto) example
                                # Selectors on topic example

                                • 13. Re: JBM 2.0 examples
                                  Tim Fox Master

                                  Howard - good start...

                                  Some initial comments:

                                  1) Can you add them to the eclipse project (I assume you use eclipse) so we can browse them?

                                  2) Each example needs a readme, structured in a standard way. We should create a template for this.

                                  Each readme.html should be formatted and written as simply and clearly as possible on a single page if possible.

                                  I suggest the following sections:

                                  a) Name of example

                                  b) Short description of example, e.g. This example demonstrates usage of a JMS durable subscription. Durable subscriptions are used when you wish to persist... blah blah blah. In this example you will create a durable subscription, send some messages to, consume some mesages, then close the subscriber, more messages will be sent when the subscriber is not connected, demonstrating the durable subscription's ability to collect messages when there is no subscriber. Then we demonstrate the subscriber reconnecting, and finally deleting the durable subscription. etc
                                  (btw don't copy the above it was just an illustration)

                                  c) Step by step of example

                                  step 1, first we create the durable subscription, blah blah

                                  step 2, now we send some messages

                                  etc

                                  each step should correspond to comments in the source code with the same step numbers.

                                  There should also be more comments in the source.

                                  Also the transactional example doesn't really demonstrate transactions - it just sends and consumes a single message so transactions are of no use. For a transaction example you should be sending multiple messages and stressing the point that the unit is atomic, also demonstrating rollback and how redelivery occurs on rollback.

                                  • 14. Re: JBM 2.0 examples
                                    Tim Fox Master

                                    In summary, clarity, accessibility and usability are the keys for good examples.

                                    Just coding it like another junit test is not going to work. ;)

                                    1 2 Previous Next