Class ReceiveSubscriber
java.lang.Object
org.apache.jmeter.protocol.jms.client.ReceiveSubscriber
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- javax.jms.MessageListener
Generic MessageConsumer class, which has two possible strategies.
 
- Use MessageConsumer.receive(timeout) to fetch messages.
- Use MessageListener.onMessage() to cache messages in a local queue.
getMessage(long) method is used to return the next message,
 either directly using receive(timeout) or from the queue using poll(timeout).- 
Constructor SummaryConstructorsConstructorDescriptionReceiveSubscriber(boolean useProps, String initialContextFactory, String providerUrl, String connfactory, String destinationName, String durableSubscriptionId, String clientId, String jmsSelector, boolean useAuth, String securityPrincipal, String securityCredentials) Constructor takes the necessary JNDI related parameters to create a connection and prepare to begin receiving messages.ReceiveSubscriber(int queueSize, boolean useProps, String initialContextFactory, String providerUrl, String connfactory, String destinationName, String durableSubscriptionId, String clientId, String jmsSelector, boolean useAuth, String securityPrincipal, String securityCredentials) Constructor takes the necessary JNDI related parameters to create a connection and create an onMessageListener to prepare to begin receiving messages.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()close() will stop the connection first.javax.jms.MessagegetMessage(long timeout) Get the next message ornull.voidonMessage(javax.jms.Message message) voidstart()Calls Connection.start() to begin receiving inbound messages.voidstop()Calls Connection.stop() to stop receiving inbound messages.
- 
Constructor Details- 
ReceiveSubscriberpublic ReceiveSubscriber(boolean useProps, String initialContextFactory, String providerUrl, String connfactory, String destinationName, String durableSubscriptionId, String clientId, String jmsSelector, boolean useAuth, String securityPrincipal, String securityCredentials) throws NamingException, javax.jms.JMSException Constructor takes the necessary JNDI related parameters to create a connection and prepare to begin receiving messages.
 The caller must then invokestart()to enable message reception.- Parameters:
- useProps- if- true, use jndi.properties instead of- initialContextFactory,- providerUrl,- securityPrincipal,- securityCredentials
- initialContextFactory- name of the initial context factory (will be ignored if- usePropsis- true)
- providerUrl- url of the provider (will be ignored if- usePropsis- true)
- connfactory- name of the object factory to look up in context
- destinationName- name of the destination
- durableSubscriptionId- id for a durable subscription (if empty or- nullno durable subscription will be done)
- clientId- client id to use (may be empty or- null)
- jmsSelector- Message Selector
- useAuth- flag whether auth should be used (will be ignored if- usePropsis- true)
- securityPrincipal- name of the principal to use for auth (will be ignored if- usePropsis- true)
- securityCredentials- credentials for the principal (will be ignored if- usePropsis- true)
- Throws:
- javax.jms.JMSException- if could not create context or other problem occurred.
- NamingException- when lookup of context or destination fails
 
- 
ReceiveSubscriberpublic ReceiveSubscriber(int queueSize, boolean useProps, String initialContextFactory, String providerUrl, String connfactory, String destinationName, String durableSubscriptionId, String clientId, String jmsSelector, boolean useAuth, String securityPrincipal, String securityCredentials) throws NamingException, javax.jms.JMSException Constructor takes the necessary JNDI related parameters to create a connection and create an onMessageListener to prepare to begin receiving messages.
 The caller must then invokestart()to enable message reception.- Parameters:
- queueSize- maximum queue size, where a- queueSize<=0 means no limit
- useProps- if- true, use jndi.properties instead of- initialContextFactory,- providerUrl,- securityPrincipal,- securityCredentials
- initialContextFactory- name of the initial context factory (will be ignored if- usePropsis- true)
- providerUrl- url of the provider (will be ignored if- usePropsis- true)
- connfactory- name of the object factory to look up in context
- destinationName- name of the destination
- durableSubscriptionId- id for a durable subscription (if empty or- nullno durable subscription will be done)
- clientId- client id to use (may be empty or- null)
- jmsSelector- Message Selector
- useAuth- flag whether auth should be used (will be ignored if- usePropsis- true)
- securityPrincipal- name of the principal to use for auth (will be ignored if- usePropsis- true)
- securityCredentials- credentials for the principal (will be ignored if- usePropsis- true)
- Throws:
- javax.jms.JMSException- if could not create context or other problem occurred.
- NamingException- when lookup of context or destination fails
 
 
- 
- 
Method Details- 
startpublic void start() throws javax.jms.JMSExceptionCalls Connection.start() to begin receiving inbound messages.- Throws:
- javax.jms.JMSException- when starting the context fails
 
- 
stoppublic void stop() throws javax.jms.JMSExceptionCalls Connection.stop() to stop receiving inbound messages.- Throws:
- javax.jms.JMSException- when stopping the context fails
 
- 
getMessagepublic javax.jms.Message getMessage(long timeout) throws javax.jms.JMSException Get the next message ornull.Never blocks for longer than the specified timeout. - Parameters:
- timeout- in milliseconds
- Returns:
- the next message or null
- Throws:
- javax.jms.JMSException- when receiving the message fails
 
- 
closepublic void close()close() will stop the connection first. Then it closes the subscriber, session and connection.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
 
- 
onMessagepublic void onMessage(javax.jms.Message message) - Specified by:
- onMessagein interface- javax.jms.MessageListener
 
 
-