Class AmqpSender

All Implemented Interfaces:
FrankElement, HasApplicationContext, HasName, HasPhysicalDestination, IConfigurable, IScopeProvider, ISender, ISenderWithParameters, IWithParameters, NameAware, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle

  • 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

    • AmqpSender

      public AmqpSender()
  • Method Details

    • configure

      public void configure() throws ConfigurationException
      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 this IConfigurable. 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 the configure(), to improve performance.

      In the case of a container, this will propagate the configure signal to all components that apply.

      Specified by:
      configure in interface IConfigurable
      Overrides:
      configure in class AbstractSenderWithParameters
      Throws:
      ConfigurationException - in case it was not able to configure the component.
    • start

      public void start()
      Description copied from interface: ISender
      This method will be called to start the sender. After this method is called the sendMessage method may be called. Purpose of this method is to reduce creating connections to databases etc. in the sendMessage() method.
      Specified by:
      start in interface ISender
      Specified by:
      start in interface org.springframework.context.Lifecycle
      Overrides:
      start in class AbstractSender
    • stop

      public void stop()
      Description copied from interface: ISender
      Stop/close the sender and deallocate resources.
      Specified by:
      stop in interface ISender
      Specified by:
      stop in interface org.springframework.context.Lifecycle
      Overrides:
      stop in class AbstractSender
    • getPhysicalDestinationName

      public String getPhysicalDestinationName()
      Specified by:
      getPhysicalDestinationName in interface HasPhysicalDestination
    • sendMessage

      @Nonnull public SenderResult sendMessage(@Nonnull Message message, @Nonnull PipeLineSession session) throws SenderException, TimeoutException
      Description copied from interface: ISender
      Send a message to some destination (as configured in the Sender object). This method may only be called after the configure() method is called.

      The following table shows the difference between synchronous and a-synchronous senders:

       synchronousa-synchronous
      ISender.isSynchronous() returnstruefalse
      return value of sendMessage() isthe reply-messagethe messageId of the message sent
      the correlationID specified with sendMessage()may be ignoredis sent with the message
      a {link TimeOutException}may be thrown if a timeout occurs waiting for a replyshould not be expected

      Multiple objects may try to call this method at the same time, from different threads. Implementations of this method should therefore be thread-safe, or synchronized.

      Specified by:
      sendMessage in interface ISender
      Throws:
      SenderException
      TimeoutException
    • setConnectionName

      public void setConnectionName(String connectionName)
    • setTimeout

      public void setTimeout(long timeout)
      Timeout in seconds for sending messages and receiving replies.
      Default value
      30L
    • setAddressType

      public void setAddressType(AddressType addressType)
      Set the type of address to which messages are being sent, TOPIC or QUEUE. For MessageProtocol#RR the type will always be QUEUE.
    • setAddress

      public void setAddress(String address)
      Set the address (name of the queue or topic) on which to send messages
    • setMessageType

      public void setMessageType(AmqpSender.MessageType messageType)
      Set the message type: AmqpSender.MessageType.TEXT to character data to be sent as AmqpValue section, AmqpSender.MessageType.BINARY for binary data to be sent as AMQP Data section, or AmqpSender.MessageType.AUTO to decide automatically based on the wether the input Message is binary or not.

      When a message is to be received as a streaming message by the recipient, it has to be sent as a AmqpSender.MessageType.BINARY message.
      When setStreamingMessages(boolean) is configured true, the messageType is ignored.

      Default value
      AUTO
    • setStreamingMessages

      public void setStreamingMessages(boolean streamingMessages)
      Set if messages should be created as streaming messages. Streaming messages are always sent as binary messages, with an AMQP Body section.
    • setDurable

      public void setDurable(boolean durable)
    • setTimeToLive

      public void setTimeToLive(long timeToLive)
      Set the message time-to-live, in milliseconds.
      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

      public void setMessageProtocol(MessageProtocol messageProtocol)
      Send message as Fire-and-Forget, or as Request-Reply
      Parameters:
      messageProtocol - FF for Fire-and-Forget, or RR for Request-Reply.
      Default value
      FF