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 longstatic final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterMessageProcessed(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.voidConfigure this component.voidextractMessage(RawMessageWrapper<org.apache.qpid.protonj2.client.Message<?>> rawMessage, Map<String, Object> context) Extracts data from message obtained fromIPullingListener.getRawMessage(Map)orIPushingListener.wrapRawMessage(Object, PipeLineSession).intintvoidbooleanbooleanvoidsetAddress(String address) Set the address (name of the queue or topic) on which to send messagesvoidsetAddressType(AddressType addressType) Set the type of address to which messages are being sent, TOPIC or QUEUE.voidsetConnectionName(String connectionName) Name of the AMQP connection in the amqp section of theresources.yamlfile.voidsetDeliveryMode(org.apache.qpid.protonj2.client.DeliveryMode deliveryMode) DeliveryMode: AT_LEAST_ONCE or AT_MOST_ONCE.voidsetDurable(boolean durable) If true, then listen for durable messages on a topicvoidsetMaxThreadCount(int maxThreadCount) voidsetMessageProtocol(MessageProtocol messageProtocol) Receive message as Fire-and-Forget, or as Request-ReplyvoidWhen an exception happens in the execution of the pipeline, withRETHROWthe exception is thrown to the caller.voidsetReplyAddress(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 areplyAddressNamecan be configured for the queue on which to send the reply message.voidsetReplyTimeToLive(long timeToLive) Set the message time-to-live, in milliseconds, for any reply messages sent by this listener.voidsetSendReplyTimeout(long timeout) Timeout in seconds for sending messages and receiving replies.voidsetSubscriptionName(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.voidstart()Prepares the listener for receiving messages.voidstop()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, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods 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:IPushingListenerWrap a raw message in a MessageWrapper. PopulatePipeLineSessionwith properties from the message.- Specified by:
wrapRawMessagein interfaceIPushingListener<org.apache.qpid.protonj2.client.Message<?>>- Parameters:
rawMessage- The raw message data, unwrappedsession-PipeLineSessionto populate with properties from the message.- Returns:
- Wrapped raw message
- Throws:
ListenerException- If any exception occurs during wrapping, aListenerExceptionis thrown.
-
configure
Description copied from interface:IConfigurableConfigure 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:
configurein interfaceIConfigurable- Throws:
ConfigurationException- in case it was not able to configure the component.
-
start
public void start()Description copied from interface:IListenerPrepares the listener for receiving messages.start()is called once each time the listener is started. -
stop
public void stop()Description copied from interface:IListenerClose 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:IListenerExtracts 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:
extractMessagein interfaceIListener<org.apache.qpid.protonj2.client.Message<?>>- Parameters:
rawMessage- TheRawMessageWrapperfrom which to extract theMessage.context- Context to populate. Either aPipeLineSessionor aMapthreadContext depending on caller.- Returns:
- input
Messagefor 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:IListenerCalled to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.- Specified by:
afterMessageProcessedin interfaceIListener<org.apache.qpid.protonj2.client.Message<?>>- Throws:
ListenerException
-
setConnectionName
Name of the AMQP connection in the amqp section of theresources.yamlfile. -
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 areplyAddressNamecan be configured for the queue on which to send the reply message. If areplyAddressNameis configured but the message does have a dynamic reply-queue, then the dynamic reply-queue is used and thereplyAddressNameis 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:
isThreadCountReadablein interfaceIThreadCountControllable
-
isThreadCountControllable
public boolean isThreadCountControllable()- Specified by:
isThreadCountControllablein interfaceIThreadCountControllable
-
getCurrentThreadCount
public int getCurrentThreadCount()- Specified by:
getCurrentThreadCountin interfaceIThreadCountControllable
-
getMaxThreadCount
public int getMaxThreadCount()- Specified by:
getMaxThreadCountin interfaceIThreadCountControllable
-
increaseThreadCount
public void increaseThreadCount()- Specified by:
increaseThreadCountin interfaceIThreadCountControllable
-
decreaseThreadCount
public void decreaseThreadCount()- Specified by:
decreaseThreadCountin interfaceIThreadCountControllable
-
setOnException
Description copied from interface:RequestReplyListenerWhen an exception happens in the execution of the pipeline, withRETHROWthe exception is thrown to the caller. WithFORMAT_AND_RETURNthe exception is processed by theAdapter.setErrorMessageFormatter(IErrorMessageFormatter)and returned as result-message of theAdapter.
The default is currentlyRETHROWfor backwards compatibility but will becomeFORMAT_AND_RETURNin a future version.- Specified by:
setOnExceptionin interfaceRequestReplyListener- Parameters:
method-RETHROWorFORMAT_AND_RETURN
-
getOnException
- Specified by:
getOnExceptionin interfaceRequestReplyListener
-