Short Description |
Ports |
Metadata |
JMSWriter Attributes |
Details |
Examples |
Best Practices |
See also |
JMSWriter converts Clover data records into JMS messages.
Component | Data output | Input ports | Output ports | Transformation | Transf. required | Java | CTL | Auto-propagated metadata |
---|---|---|---|---|---|---|---|---|
JMSWriter | jms messages | 1 | 0 |
Port type | Number | Required | Description | Metadata |
---|---|---|---|---|
Input | 0 | For data records | Any |
JMSWriter does not propagate metadata.
JMSWriter has no metadata templates.
Metadata on input port may contain a field specified in the Message body field attribute.
Attribute | Req | Description | Possible values |
---|---|---|---|
Basic | |||
JMS connection | yes | ID of the JMS connection to be used. See JMS Connections. | |
Processor code | Transformation of records to JMS messages written in the graph in Java. | ||
Processor URL | Name of external file, including path, containing the transformation of records to JMS messages written in Java. | ||
Processor class | Name of external class defining the
transformation of records to JMS messages.
The default processor value ( | DataRecord2JmsMsgProperties (default) | other class | |
Processor source charset |
Encoding of external file containing the transformation in Java. The default encoding depends on DEFAULT_SOURCE_CODE_CHARSET in defaultProperties. | UTF-8 | other encoding | |
Advanced | |||
Message body field | Name of the field of metadata from which the body of
the message should be get and sent out.
This attribute is used by the default processor implementation
(JmsMsg2DataRecordProperties ).
If no Message body field is specified, the
field whose name is bodyField will be used
as a resource for the body of the message contents.
If no field for the body of the message is contained in metadata
(either the specified explicitly or the default one), the processor
tries to set a field named bodyField, but it's silently ignored
if such field doesn't exist in output record metadata.
The other fields from metadata serve as resources of message
properties with the same names as field names. | bodyField (default) | other name |
JMSWriter receives Clover data records,
converts them into JMS messages and sends these messages out.
Component uses a processor transformation which implements a
DataRecord2JmsMsg
interface or inherits from a
DataRecord2JmsMsgBase
superclass.
Methods of DataRecord2JmsMsg
interface are described
below.
Details on threads are described in Details in JMSReader.
Data that is inserted into body or header of a message depends on the implementation of the Processor
class.
The default implementation is org.jetel.component.jms.DataRecord2JmsMsgProperties
.
Message body may be filled with textual representation of one field of the record.
You can specify name of such field by component attribute Message body field.
All the other fields are saved using string properties in the msg header. Property names are same as field names. Values contain textual representation of field values. Last message has same format as all the others. Terminating message is not used.
The transformation implements methods of the DataRecord2JmsMsg
interface
and inherits other common methods from the Transform
interface.
See Common Java Interfaces.
You can use Public Clover API too.
Following are the methods of
DataRecord2JmsMsg
interface:
void init(DataRecordMetadata metadata, Session
session, Properties props)
Initializes the processor.
void preExecute(Session session)
This is also initialization method, which is invoked before each separate graph run.
Contrary the init() procedure here should be allocated only resources for this graph run.
All here allocated resources should be released in the postExecute()
method.
session
may be used for creation of JMS messages.
Each graph execution has its own session opened.
Thus the session set in the init()
method is usable only during the first execution of graph instance.
Message createMsg(DataRecord
record)
Transforms data record to JMS message. Is called for all data records.
Message createLastMsg()
This method is called after last record and is supposed to return message terminating JMS output. If it returns null, no terminating message is sent. Since 2.8.
String getErrorMsg()
Returns error message.
Message createLastMsg(DataRecord
record)
(deprecated)
This method is not called explicitly since 2.8.
Use createLastMsg()
instead.
There is a message queue clover-queue
on localhost:61616
.
Write 5 records into the message queue.
Create a JMS Connection MyJMSConnection
.
The details are described Read Text Message from Message Queue example in documentation on JMSReader.
Configure the JMSWriter component.
Attribute | Value |
---|---|
JMS Connection | MyJMSConnection |
Message body field | e.g. field1 |
If Processor URL is used, we recommend users to explicitly specify Processor source charset.