Class MqMessage

java.lang.Object
com.mayam.wf.mq.MqMessage

public class MqMessage extends Object
A message to be sent or listened for via Mq.
Author:
Markus MÃ¥rtensson
  • Field Details

  • Constructor Details

    • MqMessage

      public MqMessage()
  • Method Details

    • injectHelpers

      @Inject public void injectHelpers(Mq mq, ValueNormalizer normalizer, com.mayam.wf.attributes.server.AttributeMapMapper mapper)
    • propertyNames

      public Set<String> propertyNames()
      Retrieves the names of properties defined within the messsage.
    • get

      public String get(String name)
      Gets a message property value.
      Parameters:
      name - property name.
      Returns:
      value.
    • get

      public <T> T get(String name, Class<T> valueClass)
      Gets a message property value, converting it to the requested class using ValueNormalizer.
      Parameters:
      name - property name.
      valueClass - expected value class.
      Returns:
      converted value.
      Throws:
      IllegalArgumentException - if the property value can not be converted into valueClass.
    • set

      public MqMessage set(String name, String value)
      Sets a message property.
      Parameters:
      name - property name.
      value - property value.
      Returns:
      the MqMessage itself, for fluid chaining purposes.
    • set

      public MqMessage set(String name, Object value)
      Sets a message property, converting the provided value to a string using ValueNormalizer.
      Parameters:
      name - property name.
      value - property value.
      Returns:
      the MqMessage itself, for fluid chaining purposes.
      Throws:
      IllegalArgumentException - if the value can not be converted into a string.
    • setProperties

      public MqMessage setProperties(Map<String,String> properties)
      Sets all message properties, replacing any already set.
      Parameters:
      properties - property map.
      Returns:
      the MqMessage itself, for fluid chaining purposes.
    • getProperties

      public Map<String,String> getProperties()
      Gets all message properties.
    • getContent

      public String getContent()
      Returns the message text content.
      Throws:
      MqException - if the content of a large message could not be retrieved via HTTP.
    • getSubject

      public AttributeMap getSubject()
      Returns an AttributeMap derived from the message text content.
    • getFullSubject

      public AttributeMap getFullSubject()
      Returns an combined before/after AttributeMap derived from the message text content.
    • getSegmentList

      public SegmentList getSegmentList()
      Returns an SegmentList derived from the message text content.
    • getSubjectPair

      public MqMessage.AttributeMapPair getSubjectPair()
      Returns an MqMessage.AttributeMapPair derived from the message text content.
    • setContent

      public MqMessage setContent(String content)
      Sets the message text content.
      Returns:
      the MqMessage itself, for fluid chaining purposes.
    • setByteContent

      public MqMessage setByteContent(byte[] byteContent)
      Sets the message byte content.
      Parameters:
      byteContent -
      Returns:
    • getByteContent

      public byte[] getByteContent()
    • hasByteContent

      public boolean hasByteContent()
    • getType

      public MqContentType getType()
      Returns the message type.
    • setType

      public MqMessage setType(MqContentType type)
      Sets the message type.
      Returns:
      the MqMessage itself, for fluid chaining purposes.
    • isLarge

      public boolean isLarge()
      Returns whether the message is too large to have its contents passed directly through the MQ.
    • setLarge

      public MqMessage setLarge(boolean large)
      Sets whether the message is too large to have its contents passed directly through the MQ.
      Returns:
      the MqMessage itself, for fluid chaining purposes.
    • send

      public void send(MqDestination destination) throws MqException
      Calls Mq.send(MqDestination, MqMessage) to send this message to a queue or topic.
      Parameters:
      destination - destination.
      Throws:
      MqException - on failure to send.
    • sendVolatile

      public void sendVolatile(MqDestination destination)
      Calls Mq.sendVolatile(MqDestination, MqMessage) to send this message to a queue or topic.
      Parameters:
      destination - destination.
    • toString

      public String toString()
      Overrides:
      toString in class Object