Class ReceiveSubscriber
java.lang.Object
org.apache.jmeter.protocol.jms.client.ReceiveSubscriber
- All Implemented Interfaces:
Closeable
,AutoCloseable
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 Summary
ConstructorsConstructorDescriptionReceiveSubscriber
(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 Summary
Modifier and TypeMethodDescriptionvoid
close()
close() will stop the connection first.Message
getMessage
(long timeout) Get the next message ornull
.void
onMessage
(Message message) void
start()
Calls Connection.start() to begin receiving inbound messages.void
stop()
Calls Connection.stop() to stop receiving inbound messages.
-
Constructor Details
-
ReceiveSubscriber
public 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, 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
- iftrue
, use jndi.properties instead ofinitialContextFactory
,providerUrl
,securityPrincipal
,securityCredentials
initialContextFactory
- name of the initial context factory (will be ignored ifuseProps
istrue
)providerUrl
- url of the provider (will be ignored ifuseProps
istrue
)connfactory
- name of the object factory to look up in contextdestinationName
- name of the destinationdurableSubscriptionId
- id for a durable subscription (if empty ornull
no durable subscription will be done)clientId
- client id to use (may be empty ornull
)jmsSelector
- Message SelectoruseAuth
- flag whether auth should be used (will be ignored ifuseProps
istrue
)securityPrincipal
- name of the principal to use for auth (will be ignored ifuseProps
istrue
)securityCredentials
- credentials for the principal (will be ignored ifuseProps
istrue
)
-
ReceiveSubscriber
public 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, 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 aqueueSize
<=0 means no limituseProps
- iftrue
, use jndi.properties instead ofinitialContextFactory
,providerUrl
,securityPrincipal
,securityCredentials
initialContextFactory
- name of the initial context factory (will be ignored ifuseProps
istrue
)providerUrl
- url of the provider (will be ignored ifuseProps
istrue
)connfactory
- name of the object factory to look up in contextdestinationName
- name of the destinationdurableSubscriptionId
- id for a durable subscription (if empty ornull
no durable subscription will be done)clientId
- client id to use (may be empty ornull
)jmsSelector
- Message SelectoruseAuth
- flag whether auth should be used (will be ignored ifuseProps
istrue
)securityPrincipal
- name of the principal to use for auth (will be ignored ifuseProps
istrue
)securityCredentials
- credentials for the principal (will be ignored ifuseProps
istrue
)
-
-
Method Details
-
start
public void start() throws JMSExceptionCalls Connection.start() to begin receiving inbound messages. -
stop
public void stop() throws JMSExceptionCalls Connection.stop() to stop receiving inbound messages. -
getMessage
public Message getMessage(long timeout) throws JMSException Get the next message ornull
.Never blocks for longer than the specified timeout.
- Parameters:
timeout
- in milliseconds- Returns:
- the next message or
null
-
close
public void close()close() will stop the connection first. Then it closes the subscriber, session and connection.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
onMessage
public void onMessage(Message message)
-