Writing a message to the dead-letter queue in C++
Example program code for writing a message to the dead-letter queue.
A typical case of a multipart message is one containing a dead-letter header. The data from a message that cannot be processed is appended to the dead-letter header.ImqQueueManager mgr ; // The queue manager. ImqQueue queueIn ; // Incoming message queue. ImqQueue queueDead ; // Dead-letter message queue. ImqMessage msg ; // Incoming and outgoing message. ImqDeadLetterHeader header ; // Dead-letter header information. // Retrieve the message to be rerouted. queueIn.setConnectionReference( mgr ); queueIn.setName( MY_QUEUE ); queueIn.get( msg ); // Set up the dead-letter header information. header.setDestinationQueueManagerName( mgr.name( ) ); header.setDestinationQueueName( queueIn.name( ) ); header.setPutApplicationName( /* ? */ ); header.setPutApplicationType( /* ? */ ); header.setPutDate( /* TODAY */ ); header.setPutTime( /* NOW */ ); header.setDeadLetterReasonCode( FB_APPL_ERROR_1234 ); // Insert the dead-letter header information. This will vary // the encoding, character set and format of the message. // Message data is moved along, past the header. msg.writeItem( header ); // Send the message to the dead-letter queue. queueDead.setConnectionReference( mgr ); queueDead.setName( mgr.deadLetterQueueName( ) ); queueDead.put( msg );Parent topic: Messaging in C++