public class ReceiveSubscriber extends Object implements Closeable, javax.jms.MessageListener
getMessage(long)
method is used to return the next message,
either directly using receive(timeout) or from the queue using poll(timeout).Constructor and Description |
---|
ReceiveSubscriber(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.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
close() will stop the connection first.
|
javax.jms.Message |
getMessage(long timeout)
Get the next message or
null . |
void |
onMessage(javax.jms.Message message) |
void |
start()
Calls Connection.start() to begin receiving inbound messages.
|
void |
stop()
Calls Connection.stop() to stop receiving inbound messages.
|
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, javax.jms.JMSException
start()
to enable message reception.useProps
- if true
, use jndi.properties instead of
initialContextFactory
, providerUrl
,
securityPrincipal
,
securityCredentials
initialContextFactory
- name of the initial context factory (will be ignored if
useProps
is true
)providerUrl
- url of the provider (will be ignored if useProps
is true
)connfactory
- name of the object factory to look up in contextdestinationName
- name of the destinationdurableSubscriptionId
- id for a durable subscription (if empty or null
no durable subscription will be done)clientId
- client id to use (may be empty or null
)jmsSelector
- Message SelectoruseAuth
- flag whether auth should be used (will be ignored if
useProps
is true
)securityPrincipal
- name of the principal to use for auth (will be ignored if
useProps
is true
)securityCredentials
- credentials for the principal (will be ignored if
useProps
is true
)javax.jms.JMSException
- if could not create context or other problem occurred.NamingException
- when lookup of context or destination failspublic 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
start()
to enable message reception.queueSize
- maximum queue size, where a queueSize
<=0
means no limituseProps
- if true
, use jndi.properties instead of
initialContextFactory
, providerUrl
,
securityPrincipal
,
securityCredentials
initialContextFactory
- name of the initial context factory (will be ignored if
useProps
is true
)providerUrl
- url of the provider (will be ignored if useProps
is true
)connfactory
- name of the object factory to look up in contextdestinationName
- name of the destinationdurableSubscriptionId
- id for a durable subscription (if empty or null
no durable subscription will be done)clientId
- client id to use (may be empty or null
)jmsSelector
- Message SelectoruseAuth
- flag whether auth should be used (will be ignored if
useProps
is true
)securityPrincipal
- name of the principal to use for auth (will be ignored if
useProps
is true
)securityCredentials
- credentials for the principal (will be ignored if
useProps
is true
)javax.jms.JMSException
- if could not create context or other problem occurred.NamingException
- when lookup of context or destination failspublic void start() throws javax.jms.JMSException
javax.jms.JMSException
- when starting the context failspublic void stop() throws javax.jms.JMSException
javax.jms.JMSException
- when stopping the context failspublic javax.jms.Message getMessage(long timeout) throws javax.jms.JMSException
null
.
Never blocks for longer than the specified timeout.
timeout
- in millisecondsnull
javax.jms.JMSException
- when receiving the message failspublic void close()
close
in interface Closeable
close
in interface AutoCloseable
public void onMessage(javax.jms.Message message)
onMessage
in interface javax.jms.MessageListener
Copyright © 1998-2016 Apache Software Foundation. All Rights Reserved.