Class AmqpListener
java.lang.Object
org.frankframework.messaging.amqp.AmqpListener
- All Implemented Interfaces:
FrankElement
,HasApplicationContext
,HasName
,IConfigurable
,IListener<org.apache.qpid.protonj2.client.Message<?>>
,IPushingListener<org.apache.qpid.protonj2.client.Message<?>>
,IScopeProvider
,IThreadCountControllable
,NameAware
,RequestReplyListener
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
@Category(EXPERIMENTAL)
@DestinationType(AMQP)
public class AmqpListener
extends Object
implements IPushingListener<org.apache.qpid.protonj2.client.Message<?>>, IThreadCountControllable, RequestReplyListener
Listener for AMQP 1.0 end-points.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.frankframework.core.RequestReplyListener
RequestReplyListener.ExceptionHandlingMethod
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterMessageProcessed
(PipeLineResult processResult, RawMessageWrapper<org.apache.qpid.protonj2.client.Message<?>> rawMessage, PipeLineSession pipeLineSession) Called to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.void
Configure this component.void
extractMessage
(RawMessageWrapper<org.apache.qpid.protonj2.client.Message<?>> rawMessage, Map<String, Object> context) Extracts data from message obtained fromIPullingListener.getRawMessage(Map)
orIPushingListener.wrapRawMessage(Object, PipeLineSession)
.int
int
void
boolean
boolean
void
setAddress
(String address) Set the address (name of the queue or topic) on which to send messagesvoid
setAddressType
(AddressType addressType) Set the type of address to which messages are being sent, TOPIC or QUEUE.void
setConnectionName
(String connectionName) Name of the AMQP connection in the amqp section of theresources.yaml
file.void
setDeliveryMode
(org.apache.qpid.protonj2.client.DeliveryMode deliveryMode) DeliveryMode: AT_LEAST_ONCE or AT_MOST_ONCE.void
setDurable
(boolean durable) If true, then listen for durable messages on a topicvoid
setMaxThreadCount
(int maxThreadCount) void
setMessageProtocol
(MessageProtocol messageProtocol) Receive message as Fire-and-Forget, or as Request-Replyvoid
When an exception happens in the execution of the pipeline, withRETHROW
the exception is thrown to the caller.void
setReplyAddress
(String replyAddress) If the adapter needs to send a reply message, and the address of the reply-queue is not dynamically set on the message, then areplyAddressName
can be configured for the queue on which to send the reply message.void
setReplyTimeToLive
(long timeToLive) Set the message time-to-live, in milliseconds, for any reply messages sent by this listener.void
setSendReplyTimeout
(long timeout) Timeout in seconds for sending messages and receiving replies.void
setSubscriptionName
(String subscriptionName) When the listener is durable, then a subscriptionName should be set so the message broker can keep track of which subscribers have already received each message.void
start()
Prepares the listener for receiving messages.void
stop()
Close all resources used for listening.RawMessageWrapper
<org.apache.qpid.protonj2.client.Message<?>> wrapRawMessage
(org.apache.qpid.protonj2.client.Message<?> rawMessage, PipeLineSession session) Wrap a raw message in a MessageWrapper.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
Methods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoader
Methods inherited from interface org.frankframework.core.IPushingListener
setExceptionListener, setHandler
-
Field Details
-
DEFAULT_TIMEOUT_SECONDS
public static final long DEFAULT_TIMEOUT_SECONDS- See Also:
-
DEFAULT_TIME_TO_LIVE
public static final long DEFAULT_TIME_TO_LIVE
-
-
Constructor Details
-
AmqpListener
public AmqpListener()
-
-
Method Details
-
wrapRawMessage
public RawMessageWrapper<org.apache.qpid.protonj2.client.Message<?>> wrapRawMessage(org.apache.qpid.protonj2.client.Message<?> rawMessage, PipeLineSession session) throws ListenerException Description copied from interface:IPushingListener
Wrap a raw message in a MessageWrapper. PopulatePipeLineSession
with properties from the message.- Specified by:
wrapRawMessage
in interfaceIPushingListener<org.apache.qpid.protonj2.client.Message<?>>
- Parameters:
rawMessage
- The raw message data, unwrappedsession
-PipeLineSession
to populate with properties from the message.- Returns:
- Wrapped raw message
- Throws:
ListenerException
- If any exception occurs during wrapping, aListenerException
is thrown.
-
configure
Description copied from interface:IConfigurable
Configure this component.configure()
is called once at startup of the framework in the configure method of the owner of thisIConfigurable
. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in theconfigure()
, to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configure
in interfaceIConfigurable
- Throws:
ConfigurationException
- in case it was not able to configure the component.
-
start
public void start()Description copied from interface:IListener
Prepares the listener for receiving messages.start()
is called once each time the listener is started. -
stop
public void stop()Description copied from interface:IListener
Close all resources used for listening. Called once each time the listener is stopped. -
extractMessage
public Message extractMessage(@Nonnull RawMessageWrapper<org.apache.qpid.protonj2.client.Message<?>> rawMessage, @Nonnull Map<String, Object> context) throws ListenerExceptionDescription copied from interface:IListener
Extracts data from message obtained fromIPullingListener.getRawMessage(Map)
orIPushingListener.wrapRawMessage(Object, PipeLineSession)
. May also extract other parameters from the message and put those into the context.- Specified by:
extractMessage
in interfaceIListener<org.apache.qpid.protonj2.client.Message<?>>
- Parameters:
rawMessage
- TheRawMessageWrapper
from which to extract theMessage
.context
- Context to populate. Either aPipeLineSession
or aMap
threadContext depending on caller.- Returns:
- input
Message
for adapter. - Throws:
ListenerException
-
afterMessageProcessed
public void afterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<org.apache.qpid.protonj2.client.Message<?>> rawMessage, PipeLineSession pipeLineSession) throws ListenerException Description copied from interface:IListener
Called to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.- Specified by:
afterMessageProcessed
in interfaceIListener<org.apache.qpid.protonj2.client.Message<?>>
- Throws:
ListenerException
-
setConnectionName
Name of the AMQP connection in the amqp section of theresources.yaml
file. -
setSendReplyTimeout
public void setSendReplyTimeout(long timeout) Timeout in seconds for sending messages and receiving replies.- Default value
- 30L
-
setAddressType
Set the type of address to which messages are being sent, TOPIC or QUEUE. For MessageProtocol#RR the type will always be QUEUE.- Default value
- QUEUE
-
setAddress
Set the address (name of the queue or topic) on which to send messages -
setReplyAddress
If the adapter needs to send a reply message, and the address of the reply-queue is not dynamically set on the message, then areplyAddressName
can be configured for the queue on which to send the reply message. If areplyAddressName
is configured but the message does have a dynamic reply-queue, then the dynamic reply-queue is used and thereplyAddressName
is ignored. -
setDurable
public void setDurable(boolean durable) If true, then listen for durable messages on a topic -
setReplyTimeToLive
public void setReplyTimeToLive(long timeToLive) Set the message time-to-live, in milliseconds, for any reply messages sent by this listener.- Default value
- -1ms, meaning no expiry.
-
setDeliveryMode
public void setDeliveryMode(org.apache.qpid.protonj2.client.DeliveryMode deliveryMode) DeliveryMode: AT_LEAST_ONCE or AT_MOST_ONCE.- Default value
- AT_LEAST_ONCE
-
setMessageProtocol
Receive message as Fire-and-Forget, or as Request-Reply- Parameters:
messageProtocol
- FF for Fire-and-Forget, or RR for Request-Reply.- Default value
- FF
-
setSubscriptionName
When the listener is durable, then a subscriptionName should be set so the message broker can keep track of which subscribers have already received each message. -
setMaxThreadCount
public void setMaxThreadCount(int maxThreadCount) -
isThreadCountReadable
public boolean isThreadCountReadable()- Specified by:
isThreadCountReadable
in interfaceIThreadCountControllable
-
isThreadCountControllable
public boolean isThreadCountControllable()- Specified by:
isThreadCountControllable
in interfaceIThreadCountControllable
-
getCurrentThreadCount
public int getCurrentThreadCount()- Specified by:
getCurrentThreadCount
in interfaceIThreadCountControllable
-
getMaxThreadCount
public int getMaxThreadCount()- Specified by:
getMaxThreadCount
in interfaceIThreadCountControllable
-
increaseThreadCount
public void increaseThreadCount()- Specified by:
increaseThreadCount
in interfaceIThreadCountControllable
-
decreaseThreadCount
public void decreaseThreadCount()- Specified by:
decreaseThreadCount
in interfaceIThreadCountControllable
-
setOnException
Description copied from interface:RequestReplyListener
When an exception happens in the execution of the pipeline, withRETHROW
the exception is thrown to the caller. WithFORMAT_AND_RETURN
the exception is processed by theAdapter.setErrorMessageFormatter(IErrorMessageFormatter)
and returned as result-message of theAdapter
.
The default is currentlyRETHROW
for backwards compatibility but will becomeFORMAT_AND_RETURN
in a future version.- Specified by:
setOnException
in interfaceRequestReplyListener
- Parameters:
method
-RETHROW
orFORMAT_AND_RETURN
-
getOnException
- Specified by:
getOnException
in interfaceRequestReplyListener
-