答复: [activemq-user] 转发: about maxMessagesPerSessions parameter

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

答复: [activemq-user] 转发: about maxMessagesPerSessions parameter

Wu, Xiaofeng1 (GE Healthcare, consultant)
Hi Jonas Lim,

You are right. I found that My test program just don't AUTO_ACKNOWLEDGE the message when onMessage processed the incoming message.And this made the broker stop to send message to client when it reach the max message setting.
When I read the JMS specification, it said that if onMessage function return, it will auto acknowledge the message to broker in AUTO_ACKNOWLEDGE mode.  But I still found message stay in Queue after onMessage return.
Should I modify the acknowledge mode and use CLIENT_ACKNOWLEDGE by my self?
Next is my test code.

    public void onMessage(final Message message) {

        // now send message to another destination
        try {
            Destination other = new ActiveMQQueue("hello.another");
            jmsTemplate.send(other, new MessageCreator() {
                    public Message createMessage(Session session) throws JMSException {
                        return message;
            }
            });
        }
        catch (JMSException e) {
            log.error("Failed to send message: " + e, e);
        }
    }

-----邮件原件-----
发件人: Jonas Lim [mailto:[hidden email]]
发送时间: 2005年11月21日 12:54
收件人: [hidden email]
主题: Re: [activemq-user] 转发: about maxMessagesPerSessions parameter


Hi Xiaofeng1,

I believe the maxMessagePerSession paramamter sets  the prefetch size of the consumer. It tells  how many messages a broker will send to the client without receiving an ack before he stops dispatching messages to the client.
Hope this helps.

Regards,
Jonas

----- Original Message -----
From: "Wu, Xiaofeng1 (GE Healthcare, consultant)" <[hidden email]>
To: <[hidden email]>
Sent: Monday, November 21, 2005 10:14 AM
Subject: [activemq-user] 转发: about maxMessagesPerSessions parameter




  _____

发件人: Wu, Xiaofeng1 (GE Healthcare, consultant)
发送时间: 2005年11月17日 17:29
收件人: '[hidden email]'
主题: about maxMessagesPerSessions parameter


I have used ActiveMQ+Jencks+JmsTemplate to build a jms program. Next snippet
is the config xml file.
But when I use the default maxMessagesPerSessions value.
It can only process a little message and hang. And it can work for a long
time when I set it to 10000. What's the mean of maxMessagesPerSessions
parameter.
  <!-- definition of JCA Connector -->
  <bean id="jencks" class="org.jencks.JCAContainer">

    <!-- lets use the default configuration of work manager and transaction
manager-->
    <property name="bootstrapContext">
      <bean class="org.jencks.factory.BootstrapContextFactoryBean">
        <property name="threadPoolSize" value="200"/>
      </bean>
    </property>

    <!-- the JCA Resource Adapter -->
    <property name="resourceAdapter">
      <bean id="activeMQResourceAdapter"
class="org.activemq.ra.ActiveMQResourceAdapter">
        <property name="serverUrl" value="tcp://localhost:61616"/>
      </bean>
    </property>
  </bean>
...
  <!-- Spring JMS Template -->
  <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory">

      <!-- use the same JMS Session to publish on -->
      <bean class="org.activemq.ra.jms.ConnectionProxyFactory"/>
    </property>
    <property name="explicitQosEnabled" value="true"/>
    <property name="timeToLive" value="10000"/>
  </bean>
...
  <bean id="getInfoStage" class="org.jencks.JCAConnector">
    <property name="jcaContainer" ref="jencks" />
    <property name="activationSpec">
      <bean class="org.activemq.ra.ActiveMQActivationSpec">
        <property name="destination" value="task.getInfo"/>
        <property name="destinationType" value="javax.jms.Queue"/>
  <property name="maxSessions" value="100"/>
  <property name="maxMessagesPerSessions" value="10000"/>
      </bean>
    </property>
    <property name="ref" value="getInfoTask" />
  </bean>

  <bean id="getInfoTask" class="..." singleton="true">
        <property name="temp" ref="jmsTemplate"
  </bean>


Reply | Threaded
Open this post in threaded view
|

Re: [activemq-user] 转发: about maxMessagesPerSessions parameter

jlim
That should be the case. The broker should automatically auto acknowlege the
message after the onMessage returns. I assume   when you created  the
session you set the acknowledgemode to AUTO_ACKNOWLEDGE  (ie.
connection.createSession(false, Session.AUTO_ACKNOWLEDGE) ) ?

I did a simple test and saw that the messages where being acknowledge on
autoacknowledge mode. Below is snippet of my test :
                  ......

        Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
        Queue queue = session.createQueue("test");
        MessageProducer producer = session.createProducer(queue);
        producer.send(session.createTextMessage("Hello"));

        // Consume the message...
        MessageConsumer consumer = session.createConsumer(queue);
        consumer.setMessageListener(this);

        //wait a bit to give consumer time to consume the queue
        Thread.sleep(1000);

        // Reset the session.
        session.close();

        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

        // Attempt to Consume the message...
        consumer = session.createConsumer(queue);
        Message msg = consumer.receive(1000);

        //there no message consume since message has already been
acknowledge
        assertNull(msg);

        session.close();

                      .....

       public void onMessage(Message message){

        assertNotNull(message);
       }


Regards,
Jonas


----- Original Message -----
From: "Wu, Xiaofeng1 (GE Healthcare, consultant)" <[hidden email]>
To: <[hidden email]>
Sent: Monday, November 21, 2005 4:16 PM
Subject: ??: [activemq-user] ??: about maxMessagesPerSessions parameter


> Hi Jonas Lim,
>
> You are right. I found that My test program just don't AUTO_ACKNOWLEDGE
> the message when onMessage processed the incoming message.And this made
> the broker stop to send message to client when it reach the max message
> setting.
> When I read the JMS specification, it said that if onMessage function
> return, it will auto acknowledge the message to broker in AUTO_ACKNOWLEDGE
> mode.  But I still found message stay in Queue after onMessage return.
> Should I modify the acknowledge mode and use CLIENT_ACKNOWLEDGE by my
> self?
> Next is my test code.
>
>    public void onMessage(final Message message) {
>
>        // now send message to another destination
>        try {
>            Destination other = new ActiveMQQueue("hello.another");
>            jmsTemplate.send(other, new MessageCreator() {
>                    public Message createMessage(Session session) throws
> JMSException {
>                        return message;
>     }
>            });
>        }
>        catch (JMSException e) {
>            log.error("Failed to send message: " + e, e);
>        }
>    }
>
> -----????-----
> ???: Jonas Lim [mailto:[hidden email]]
> ????: 2005?11?21? 12:54
> ???: [hidden email]
> ??: Re: [activemq-user] ??: about maxMessagesPerSessions parameter
>
>
> Hi Xiaofeng1,
>
> I believe the maxMessagePerSession paramamter sets  the prefetch size of
> the consumer. It tells  how many messages a broker will send to the client
> without receiving an ack before he stops dispatching messages to the
> client.
> Hope this helps.
>
> Regards,
> Jonas
>
> ----- Original Message -----
> From: "Wu, Xiaofeng1 (GE Healthcare, consultant)" <[hidden email]>
> To: <[hidden email]>
> Sent: Monday, November 21, 2005 10:14 AM
> Subject: [activemq-user] ??: about maxMessagesPerSessions parameter
>
>
>
>
>  _____
>
> ???: Wu, Xiaofeng1 (GE Healthcare, consultant)
> ????: 2005?11?17? 17:29
> ???: '[hidden email]'
> ??: about maxMessagesPerSessions parameter
>
>
> I have used ActiveMQ+Jencks+JmsTemplate to build a jms program. Next
> snippet
> is the config xml file.
> But when I use the default maxMessagesPerSessions value.
> It can only process a little message and hang. And it can work for a long
> time when I set it to 10000. What's the mean of maxMessagesPerSessions
> parameter.
>  <!-- definition of JCA Connector -->
>  <bean id="jencks" class="org.jencks.JCAContainer">
>
>    <!-- lets use the default configuration of work manager and transaction
> manager-->
>    <property name="bootstrapContext">
>      <bean class="org.jencks.factory.BootstrapContextFactoryBean">
>        <property name="threadPoolSize" value="200"/>
>      </bean>
>    </property>
>
>    <!-- the JCA Resource Adapter -->
>    <property name="resourceAdapter">
>      <bean id="activeMQResourceAdapter"
> class="org.activemq.ra.ActiveMQResourceAdapter">
>        <property name="serverUrl" value="tcp://localhost:61616"/>
>      </bean>
>    </property>
>  </bean>
> ...
>  <!-- Spring JMS Template -->
>  <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
>    <property name="connectionFactory">
>
>      <!-- use the same JMS Session to publish on -->
>      <bean class="org.activemq.ra.jms.ConnectionProxyFactory"/>
>    </property>
>    <property name="explicitQosEnabled" value="true"/>
>    <property name="timeToLive" value="10000"/>
>  </bean>
> ...
>  <bean id="getInfoStage" class="org.jencks.JCAConnector">
>    <property name="jcaContainer" ref="jencks" />
>    <property name="activationSpec">
>      <bean class="org.activemq.ra.ActiveMQActivationSpec">
>        <property name="destination" value="task.getInfo"/>
>        <property name="destinationType" value="javax.jms.Queue"/>
>  <property name="maxSessions" value="100"/>
>  <property name="maxMessagesPerSessions" value="10000"/>
>      </bean>
>    </property>
>    <property name="ref" value="getInfoTask" />
>  </bean>
>
>  <bean id="getInfoTask" class="..." singleton="true">
>        <property name="temp" ref="jmsTemplate"
>  </bean>
>
>

Reply | Threaded
Open this post in threaded view
|

[activemq-user] going mad over SSL transport & firewall traversal

jmatthewpryor
I have a pretty simple client-server setup and it works fine when both
processes run on the same machine.

When I split it over a firewall, the client never receives any responses
from the server.

I can see from the log that the client thinks it has connected to the
server and the server reports that is has added a new client, but then
the client always times out.

Now I have set the SSL transport to use IP port 62617 and I have opened
that port up in the firewall. I know its open because I can use
something like telnet to connect to the server.

However I can never get a reply. Is there some other IP port that also
has to be opened up? Does the response traffic use a different connection?

Thanks for any help you can offer

Matthew
Reply | Threaded
Open this post in threaded view
|

Re: [activemq-user] going mad over SSL transport & firewall traversal

jmatthewpryor
I forgot to mention that I am using an embedded broker on the server

J. Matthew Pryor wrote:

> I have a pretty simple client-server setup and it works fine when both
> processes run on the same machine.
>
> When I split it over a firewall, the client never receives any
> responses from the server.
>
> I can see from the log that the client thinks it has connected to the
> server and the server reports that is has added a new client, but then
> the client always times out.
>
> Now I have set the SSL transport to use IP port 62617 and I have
> opened that port up in the firewall. I know its open because I can use
> something like telnet to connect to the server.
>
> However I can never get a reply. Is there some other IP port that also
> has to be opened up? Does the response traffic use a different
> connection?
>
> Thanks for any help you can offer
>
> Matthew