Class InternalMessage

java.lang.Object
com.appiancorp.suiteapi.messaging.InternalMessage
Direct Known Subclasses:
InternalJmsMessage

public class InternalMessage extends Object
Represents a message in the Appian Messaging framework. Messages can be easily converted from a javax.jms.Message object to an InternalMessage object by constructing the InternalMessage using InternalMessage(Message), and from an InternalMessage object to a javax.jms.Message using populateJavaxJmsMessage(Message).
  • Field Details

    • PROCESS_TO_PROCESS

      public static final String PROCESS_TO_PROCESS
      Message type name for a message sent from Appian Process to Appian Process (e.g., a Send Message event would send this type of message to a Receive Message event).
      See Also:
    • EXTERNAL_TO_PROCESS

      public static final String EXTERNAL_TO_PROCESS
      Message type name for a message sent from a non-Appian Process application to Appian Process (e.g., a message sent from PeopleSoft to a Receive Message event). This message type is not used for all messages from non-Appian Process applications. It should only be used as the default when no more suitable message type exists. For instance, e-mail messages will use the MAIL message type.
      See Also:
    • MAIL

      public static final String MAIL
      Message type name for a message sent via e-mail to Appian Process. E-mail messages are processed by Apache James and are then sent into Appian Process.
      See Also:
    • SUCCESS_CODE

      public static final int SUCCESS_CODE
      Result code returned from the MessagePublisherService or ProcessExecutionService.handleMessages(InternalMessage[]) indicating that the message was successfully sent.
      See Also:
    • JMS_TYPE_NOT_PROVIDED_CODE

      public static final int JMS_TYPE_NOT_PROVIDED_CODE
      Result code returned from the MessagePublisherService or ProcessExecutionService.handleMessages(InternalMessage[]) indicating that the message could not be sent because the JMS type was not provided.
      See Also:
    • INVALID_USERNAME_CODE

      public static final int INVALID_USERNAME_CODE
      Result code returned from the MessagePublisherService or ProcessExecutionService.handleMessages(InternalMessage[]) indicating that the message could not be sent because the username provided was invalid.
      See Also:
    • DESTINATION_NOT_PROVIDED_CODE

      public static final int DESTINATION_NOT_PROVIDED_CODE
      Result code returned from the MessagePublisherService or ProcessExecutionService.handleMessages(InternalMessage[]) indicating that the message could not be sent because none of the destination fields were not filled in.
      See Also:
    • DUPLICATE_MESSAGE_CODE

      public static final int DUPLICATE_MESSAGE_CODE
      Result code returned from the MessagePublisherService or ProcessExecutionService.handleMessages(InternalMessage[]) indicating that the message was not sent because a message with the same ID had previously been sent.
      See Also:
    • MESSAGE_UNDELIVERED_CODE

      public static final int MESSAGE_UNDELIVERED_CODE
      Result code to indicate the message was not delivered to the server as the server was down.
      See Also:
    • DESTINATION_PMUUID_KEY

      public static final String DESTINATION_PMUUID_KEY
      Property name for the message property containing the UUIDs for destination process models. The data stored in this property should be an externalized form of an array of strings ( AppianType.STRING).
      See Also:
    • DESTINATION_PROCESS_ID_KEY

      public static final String DESTINATION_PROCESS_ID_KEY
      Property name for the message property containing the IDs for destination processes. The data stored in this property should be an externalized form of an array of longs (TypedVariableTypes.LONG). Note that you can set this property by calling setDestinationProcessID(Long[]).
      See Also:
    • DESTINATION_PROCESS_MODEL_ID_KEY

      public static final String DESTINATION_PROCESS_MODEL_ID_KEY
      Property name for the message property containing the IDs for destination process models. The data stored in this property should be an externalized form of an array of longs (TypedVariableTypes.LONG). Note that you can set this property by calling setDestinationPMID(Long[]) .
      See Also:
    • DESTINATION_EVENT_PERSISTENT_ID_KEY

      public static final String DESTINATION_EVENT_PERSISTENT_ID_KEY
      Property name for the message property containing the persistent IDs for destination events. The data stored in this property should be an externalized form of an array of strings ( AppianType.STRING). Note that you can set this property by calling setDestinationEventPersistentID(String[]).
      See Also:
    • JMS_TYPE_KEY

      public static final String JMS_TYPE_KEY
      Property name for the message property containing the message type. Message types can be configured in message-types.xml. This property is required for all messages sent to Appian Process, and is automatically set for all messages sent from Appian Process.
      See Also:
    • JMS_TYPE_KEY_BC

      public static final String JMS_TYPE_KEY_BC
      See Also:
    • USERNAME_KEY

      public static final String USERNAME_KEY
      Property name for the message property containing the username of the user that sent the message. This property is required for all messages sent to Appian Process, and is automatically set for all messages sent from Appian Process.
      See Also:
    • MAIL_ATTACHMENTS_KEY

      public static final String MAIL_ATTACHMENTS_KEY
      (Email message types only) Property name for the message property containing the document IDs of any e-mail attachments that were saved into Appian Content. The data stored in this property should be an externalized form of an array of document IDs (AppianType.DOCUMENT ).
      See Also:
    • MAIL_KEY_KEY

      public static final String MAIL_KEY_KEY
      (Email message types only) Property name for the message property containing the key from the subject of the e-mail. The data stored in this property should be a string (AppianType.STRING). Keys can be placed in the subject of an e-mail, and are enclosed between [ and ] markers. For example, if the e-mail subject were "[ticket-142] My Ticket", the key would be "ticket-142".
      See Also:
    • MAIL_SUBJECT_KEY

      public static final String MAIL_SUBJECT_KEY
      (Email message types only) Property name for the message property containing subject of the e-mail, in its original form. The key is not removed from the subject. The data stored in this property should be a string ( AppianType.STRING).
      See Also:
  • Constructor Details

    • InternalMessage

      public InternalMessage()
      Default constructor. Required for return converters.
    • InternalMessage

      public InternalMessage(javax.jms.Message javaxJmsMessage_) throws javax.jms.JMSException
      Constructs a new InternalMessage based on an existing JMS message ( javax.jms.Message). All of the message properties with valid names are copied from the JMS message into the new InternalMessage (property name validity is determined by calling validatePropertyName(String)). In addition, if the JMS message is a TextMessage, the body is also copied from the JMS message into the new InternalMessage. A log4j message will be printed out with a log level of WARN if the message property has an invalid name.
      Parameters:
      javaxJmsMessage_ - the JMS message to populate the newly constructed object from
      Throws:
      javax.jms.JMSException - if any exceptions are thrown from the JMS methods
  • Method Details

    • processModelId

      public static String processModelId(Long pmid)
      Generate String suitable for setting InternalMessage.DESTINATION_PROCESS_MODEL_ID_KEY
      Parameters:
      pmid -
      Returns:
    • processModelIds

      public static String processModelIds(Long[] pmids)
      Generate String suitable for setting InternalMessage.DESTINATION_PROCESS_MODEL_ID_KEY
      Parameters:
      pmids -
      Returns:
    • processModelIds

      public static String processModelIds(List<Long> listPmids)
      Generate String suitable for setting InternalMessage.DESTINATION_PROCESS_MODEL_ID_KEY
      Parameters:
      pmids -
      Returns:
    • processId

      public static String processId(Long pid)
      Generate String suitable for setting InternalMessage.DESTINATION_PROCESS_MODEL_ID_KEY
      Parameters:
      pmid -
      Returns:
    • processIds

      public static String processIds(Long[] pids)
      Generate String suitable for setting InternalMessage.DESTINATION_PROCESS_MODEL_ID_KEY
      Parameters:
      pmids -
      Returns:
    • processIds

      public static String processIds(List<Long> listPids)
      Generate String suitable for setting InternalMessage.DESTINATION_PROCESS_MODEL_ID_KEY
      Parameters:
      pmids -
      Returns:
    • processModelUUID

      public static String processModelUUID(String uuid)
      Generate String suitable for setting InternalMessage.DESTINATION_PMUUID_KEY
      Parameters:
      uuid -
      Returns:
    • processModelUUIDs

      public static String processModelUUIDs(String[] uuids)
      Generate String suitable for setting InternalMessage.DESTINATION_PMUUID_KEY
      Parameters:
      uuids -
      Returns:
    • processModelUUIDs

      public static String processModelUUIDs(List<String> listUuids)
      Generate String suitable for setting InternalMessage.DESTINATION_PMUUID_KEY
      Parameters:
      uuids -
      Returns:
    • eventPersistentUUID

      public static String eventPersistentUUID(String uuid)
      Generate String suitable for setting InternalMessage.DESTINATION_EVENT_PERSISTENT_ID_KEY
      Parameters:
      uuid -
      Returns:
    • eventPersistentUUIDs

      public static String eventPersistentUUIDs(String[] uuids)
      Generate String suitable for setting InternalMessage.DESTINATION_EVENT_PERSISTENT_ID_KEY
      Parameters:
      uuids -
      Returns:
    • eventPersistentUUIDs

      public static String eventPersistentUUIDs(List<String> listUuids)
      Generate String suitable for setting InternalMessage.DESTINATION_EVENT_PERSISTENT_ID_KEY
      Parameters:
      uuids -
      Returns:
    • getBody

      public String getBody()
      Gets the message body. If this value begins with an equals sign (=), it will be interpreted as an expression by the Appian Process engine.
      Returns:
      the message body
    • setBody

      public void setBody(String body_)
      Sets the message body. If this value begins with an equals sign (=), it will be interpreted as an expression by the Appian Process engine.
      Parameters:
      body_ - the message body
      See Also:
    • getId

      public Long getId()
      Gets the message ID. In a Multiple Execution Server environment, each message ID has the source server's ID encoded into it. The message ID is also used to eliminate messages from being processed more than once by the same server.
      Returns:
      the message ID
      See Also:
    • setId

      public void setId(Long id_)
      Sets the message ID. This is set by the database server that sends the message, and should not be set from Java.
      Parameters:
      id_ - the message ID
      See Also:
    • getProperties

      public Map getProperties()
      Gets the message properties. In the map returned, the keys are the property names, and the values are the property values.
      Returns:
      the message property map
      See Also:
    • setProperties

      public void setProperties(Map properties_)
      Sets the message properties.
      Parameters:
      properties_ - the message property map
      See Also:
    • setProperty

      public void setProperty(String name_, Object value_)
      Sets the specified message property to the given value. This is the equivalent of calling setProperty(String, Object, boolean) with the externalized_ parameter set to false.
      Parameters:
      name_ - the property name
      value_ - the value
      See Also:
    • setPropertyBestType

      public void setPropertyBestType(String name_, String strRep_)
      Sets the specified message property using the "best fit" type. This means that it attempts to maximize the number of types it can be converted to in JMS messages via JMS's auto-conversion requirements (e.g., 123 would be set as a Byte, since JMS can automatically convert that to Byte, Short, Integer, Long, or String, depending on which getter is used). Uses AppianBeanUtils.convertToBestFitType(java.lang.String, boolean) . Note that this does not minimize the number of bytes necessary to represent a number, such as converting 125 from a Long into a Byte. The minimizeTypeSizes() method does that.
      Parameters:
      name_ - the property name
      strRep_ - the value
    • setProperty

      public void setProperty(String name_, Object value_, boolean externalized_)
      Sets the specified message property to the value, and sets the externalized map entry for that property to the boolean passed in. Note that it does not automatically externalize the value passed in. It leaves the value passed in as is. If you want it to automatically externalize the value, call setExternalizedProperty(String, Object, Long, boolean)
      Parameters:
      name_ - the property name
      value_ - the value
      externalized_ - whether the value has been externalized
      See Also:
    • setSmartProperty

      public void setSmartProperty(String name, Object value)
      Determines if a value is plain, comma-delimited or externalized, and sets accordingly. 123 is an id destination (all digits) 0001d0c7-d9ae-8000-d9ae-57b76157b761 is a UUID destination (all hex-digits an -, 8-4-4-4-12) 01000000200000000000000003000000040000006162630001000000030000000100000002000000 is an externalized destination (>=80 hex-digits) 123,45,67890123 is a list of ids uuid, uuid, uuid is a list of uuids (list of externals is not allowed, and unnecessary, as it's embedded) Number (Integer, Long) values are allowed for ids.
      Parameters:
      name -
      value -
    • getProperty

      public Object getProperty(String name_)
      Gets the named property.
      Parameters:
      name_ - the name of the property
      Returns:
      the property value
      See Also:
    • setExternalizedProperty

      public void setExternalizedProperty(String name_, Object value_, long type_, boolean multiple_)
      Externalizes the value and sets the specified message property to the value provided.
      Parameters:
      name_ - the property name
      value_ - the value
      type_ - the type to convert (in TypedVariable)
      multiple_ - whether it can contain multiple valuse
      See Also:
    • setExternalizedProperty

      public void setExternalizedProperty(String name_, Object value_, Long type_, boolean multiple_)
      Externalizes the value and sets the specified message property to the value provided.
      Parameters:
      name_ - the property name
      value_ - the value
      type_ - the type to convert (in TypedVariable)
      multiple_ - whether it can contain multiple valuse
    • internalizeExternalizedProperty

      public TypedVariable internalizeExternalizedProperty(String name_)
      Returns the internalized version of the externalized property.
      Parameters:
      name_ - the property name
      Returns:
      the TypedVariable representation
    • setMessageType

      public void setMessageType(String jmsType_)
      Sets the message type (JMS_TYPE_KEY) to the type passed in.
      Parameters:
      jmsType_ - the message type (one of PROCESS_TO_PROCESS, EXTERNAL_TO_PROCESS, MAIL, or a custom type
      See Also:
    • setJMSType

      public void setJMSType(String jmsType_)
    • getMessageType

      public String getMessageType()
      Gets the message type (JMS_TYPE_KEY).
      Returns:
      the message type
      See Also:
    • getJMSType

      public String getJMSType()
    • getPropertyExternalizationStates

      public Map getPropertyExternalizationStates()
      Gets the message property externalization states. In this Map, the keys are the property names, and the values are whether the corresponding properties were externalized (1 or Boolean.TRUE for yes, 0 or Boolean.FALSE for no).
      Returns:
      the externalization states
      See Also:
    • setPropertyExternalizationStates

      public void setPropertyExternalizationStates(Map propertyExternalizationStates_)
      Sets the message property externalization states.
      Parameters:
      propertyExternalizationStates_ - the property externalization states map. The keys must be the property names, and the values must be Booleans.
      See Also:
    • setPropertyExternalizationState

      public void setPropertyExternalizationState(String name_, boolean isExternalized_)
      Sets the message property externalization state for the specified property.
      Parameters:
      name_ - the name of the property
      isExternalized_ - whether the property is externalized
      See Also:
    • getPropertyExternalizationState

      public boolean getPropertyExternalizationState(String name_)
      Gets the message property externalization state for the specified property.
      Parameters:
      name_ - the name of the property
      Returns:
      the externalization state
      See Also:
    • populateJavaxJmsMessage

      public javax.jms.Message populateJavaxJmsMessage(javax.jms.Message javaxJmsMessage_) throws javax.jms.JMSException
      Populates the JMS message with the body and properties of this message.
      Parameters:
      javaxJmsMessage_ - the JMS message, generated by the JMS API
      Returns:
      the same JMS message, with the properties and body populated
      Throws:
      javax.jms.JMSException - if any errors occur in any JMS methods
    • setDestinationPMID

      public void setDestinationPMID(Long[] processModelIds_)
      Sets the destination PM ID property (which process models the message will be sent to). Note that the PM ID is actually stored in externalized form.
      Parameters:
      processModelIds_ - the PM IDs
      See Also:
    • setDestinationPMUUID

      public void setDestinationPMUUID(String[] processModelUuids)
      Sets the destination PM UUID property (which process models the message will be sent to). Note that the PM UUID is actually stored in externalized form.
      Parameters:
      processModelUuids -
    • getDestinationPMID

      public Long[] getDestinationPMID()
      Gets the destination PM IDs (which process models the message will be sent to). Note that the PM ID is actually stored in externalized form. Therefore, if you call getProperty(String), it will return the externalized string.
      Returns:
      the destination PM IDs
      See Also:
    • getDestinationPMUUID

      public String[] getDestinationPMUUID()
      Gets the destination PM UUIDs (which process models the message will be sent to). Note that the PM ID is actually stored in externalized form. Therefore, if you call getProperty(String), it will return the externalized string.
      Returns:
      the destination PM IDs
      See Also:
      • #setDestinationPMUUID(Long[])
    • setDestinationEventPersistentID

      public void setDestinationEventPersistentID(String[] eventPersistentIds_)
      Sets the destination event persistent ID property (which events the message will be sent to). Note that the event persistent ID is actually stored in externalized form.
      Parameters:
      eventPersistentIds_ - the event persistent IDs
      See Also:
    • getDestinationEventPersistentID

      public String[] getDestinationEventPersistentID()
      Gets the destination event persistent IDs (which events the message will be sent to). Note that the event persistent ID is actually stored in externalized form. Therefore, if you call getProperty(String), it will return the externalized string.
      Returns:
      the destination PM IDs
      See Also:
    • setDestinationProcessID

      public void setDestinationProcessID(Long[] processIds_)
      Sets the destination process ID property (which processes the message will be sent to). Note that the process ID is actually stored in externalized form.
      Parameters:
      processIds_ - the process IDs
      See Also:
    • getDestinationProcessID

      public Long[] getDestinationProcessID()
      Gets the destination process IDs (which processes the message will be sent to). Note that the process ID is actually stored in externalized form. Therefore, if you call getProperty(String), it will return the externalized string.
      Returns:
      the destination PM IDs
      See Also:
    • setUserName

      public void setUserName(String username_)
      Sets the UserName property. When the message is sent to Appian Process, it will be considered to have come from this user.
      Parameters:
      username_ - the username
      See Also:
    • getUserName

      public String getUserName()
      Gets the UserName property.
      Returns:
      the username
      See Also:
    • minimizeTypeSizes

      public void minimizeTypeSizes()
      Makes the underlying storage for all of the properties the smallest it can be but still storing the data. For instance, the number 20 will be stored in a byte rather than in an integer. This is important for interoperability with JMS because the JMS message supports getting the long representation of a byte, but cannot get the byte representation of a long.
    • validatePropertyName

      public static boolean validatePropertyName(String propertyName_)
      Checks if property name is valid. Valid characters for the first position include numeric digits (0..9), upper-case (A..Z) and lower-case (a..z) letters. Valid characters for other positions also include underscore (_). This calls validatePropertyNameChar(char) on each character other than first.
      Parameters:
      propertyName_ - the property name to validate
      Returns:
      true if the name passed in contains only valid characters
    • validatePropertyNameChar

      public static boolean validatePropertyNameChar(char c_)
      Checks whether a character is allowed in a property name. Valid characters for the first position include numeric digits (0..9), upper-case (A..Z) and lower-case (a..z) letters. Valid characters for other positions also include underscore (_).
      Parameters:
      c_ - the character to validate
      Returns:
      true if the character passed in is valid
    • shouldGoToAllServers

      public boolean shouldGoToAllServers()
      Checks whether the message should go to design and all execution servers. It should go to all servers if any process model or event destinations are specified. If only process destinations are specified, it should only be sent to the appropriate execution servers.
      Returns:
      true if it should go to all servers
    • toString

      public String toString()
      String representation of this object. Currently only displays the Id and Body of the message.
      Overrides:
      toString in class Object
    • externalizeBooleanProperties

      public void externalizeBooleanProperties()
      Externalizes all Boolean properties so that they are handled correctly by Expression. This should only occur immediately before sending the message to Appian Process. Note that this modifies the actual property values in the InternalMessage.
    • routeToProcessModel

      public static void routeToProcessModel(javax.jms.Message message, String processModelUuid, String username) throws javax.jms.JMSException
      Populate the JMS Message with routing information to the given process model from the given username. This broadcasts to all instances of the process model, as well as the process model's start event. The process model UUID is shown under the process model properties. It will continue to be the same upon exporting and importing the process model. This does NOT actually send the message anywhere.
      Parameters:
      message - : this is the message to be populated
      processModelUuid -
      username - : this is the nominal source username
      Throws:
      javax.jms.JMSException
    • routeToProcessModel

      public static void routeToProcessModel(javax.jms.Message message, Long processModelId, String username) throws javax.jms.JMSException
      Populate the JMS Message with routing information to the given process model from the given username. This broadcasts to all instances of the process model, as well as the process model's start event. The process model ID is particular to an installation; it will not remain the same upon exporting and importing the process model. This method is useful particularly for sending messages to process models created programmatically. This does NOT actually send the message anywhere.
      Parameters:
      message - : this is the message to be populated
      processModelId -
      username - : this is the nominal source username
      Throws:
      javax.jms.JMSException
    • routeToEventPersistentId

      public static void routeToEventPersistentId(javax.jms.Message message, String eventPersistentUuid, String username) throws javax.jms.JMSException
      Populate the JMS Message with routing information to the given event persistent id from the given username. This broadcasts to all nodes with the given UUID. This may be routed to either a process model's start node with receive event or a process node receive event. The event persistent id shows under Event Properties as Persistent ID. It is the form of a UUID particular to each receive node. This does NOT actually send the message anywhere.
      Parameters:
      message - : this is the message to be populated
      uuid - event persistent UUID
      username - : this is the nominal source username
      Throws:
      javax.jms.JMSException
    • routeToEventPersistentId

      public static void routeToEventPersistentId(javax.jms.Message message, Long processId, String eventPersistentUuid, String username) throws javax.jms.JMSException
      Populate the JMS Message with routing information to the given event persistent id from the given username. This broadcasts to all nodes with the given UUID. This may be routed to either a process model's start node with receive event or a process node receive event. The event persistent id shows under Event Properties as Persistent ID. It is the form of a UUID particular to each receive node. This does NOT actually send the message anywhere.
      Parameters:
      message - : this is the message to be populated
      uuid - event persistent UUID
      username - : this is the nominal source username
      Throws:
      javax.jms.JMSException
    • routeToEventPersistentId

      public static void routeToEventPersistentId(javax.jms.Message message, String processModelUuid, String eventPersistentUuid, String username) throws javax.jms.JMSException
      Populate the JMS Message with routing information to the given event persistent id from the given username. This broadcasts to all nodes with the given UUID. This may be routed to either a process model's start node with receive event or a process node receive event. The event persistent id shows under Event Properties as Persistent ID. It is the form of a UUID particular to each receive node. This does NOT actually send the message anywhere.
      Parameters:
      message - : this is the message to be populated
      uuid - event persistent UUID
      username - : this is the nominal source username
      Throws:
      javax.jms.JMSException
    • routeToProcess

      public static void routeToProcess(javax.jms.Message message, Long processId, String username) throws javax.jms.JMSException
      Populate the JMS Message with routing information to the given process from the given username. This broadcasts to all receives in the process. The process model UUID is shown under the process model properties. It will continue to be the same upon exporting and importing the process model. This does NOT actually send the message anywhere.
      Parameters:
      message - : this is the message to be populated
      processId -
      username - : this is the nominal source username
      Throws:
      javax.jms.JMSException