How to Format Messages for Queueing

What is the best way to format messages for queueing?

You can pick any of the following MQ implementations in PHP, so you don't have to roll your own and you can look at their sourcecode to learn about their implementation. For general integration, have a look at the ActiveMQ page on Enterprise Integration patterns.

  • http://sourceforge.net/projects/beanstalk/

    A PHP Client Library for beanstalkd. BeanStalk allows PHP developers to make use of the beanstalkd in-memory workqueue server (http://xph.us/software/beanstalkd).

  • http://kr.github.com/beanstalkd/

    Beanstalk is a simple, fast workqueue service. Its interface is generic, but was originally designed for reducing the latency of page views in high-volume web applications by running time-consuming tasks asynchronously.

  • http://activemq.apache.org/

    Apache ActiveMQ is the most popular and powerful open source messaging and Integration Patterns provider. Apache ActiveMQ is fast, supports many Cross Language Clients and Protocols, comes with easy to use Enterprise Integration Patterns and many advanced features while fully supporting JMS 1.1 and J2EE 1.4. Apache ActiveMQ is released under the Apache 2.0 License

  • http://memcachedb.org/memcacheq/

    Memcachedb is a distributed key-value storage system designed for persistent. It is not a cache solution, but a persistent storage for high-frequency writing and reading. It conforms to memcache protocol(not completed, see below), so any memcached client can have connectivity with it. Memcachedb uses Berkeley DB as a storing backend, so lots of features including transaction and replication are supported.

  • http://www.zend.com/en/products/server/

    Zend Server 5.0 incorporates Job Queue, providing full support for creating, executing and managing jobs to optimize application performance and reduce server load, minimizing application bottlenecks and improving the end-user experience.

  • https://www.dropr.org/

    dropr is a distributed message queue framework written in PHP. The main goals are:

    • reliable and durable (failsafe)-messaging over networks
    • decentralized architecture without a single (point of failure) server instance
    • easy to setup and use
    • modularity for queue storage and message transports (currently filesystem storage and curl-upload are implemented)
  • http://gearman.org/

    Gearman provides a generic application framework to farm out work to other machines or processes that are better suited to do the work. It allows you to do work in parallel, to load balance processing, and to call functions between languages.

  • http://www.zeromq.org/

    ØMQ (also spelled ZeroMQ, 0MQ or ZMQ) is a high-performance asynchronous messaging library aimed at use in scalable distributed or concurrent applications. It provides a message queue, but unlike message-oriented middleware, a ØMQ system can run without a dedicated message broker. The library is designed to have a familiar socket-style API.

Message Queues with different message types

You might consider not storing your object in the MSMQ message, but instead putting a reference to it's persistent location if you can. MSMQ has finite space on the message queues, so smaller messages are best.

If you can't do that, you can serialize your object to the messages BodyStream directly, using whatever serializer you like. Then store the type name as well, probably best in the message Label.

Something very similar to this (scratched it out here, no IDE on this computer) to put it in, and the analagous action on the way out:

public void FormatObject(object toFormat, Message message)
{
var serializer = new XmlSerializer(toFormat.GetType());
var stream = new MemoryStream();
serializer.Serialize(toFormat, stream);

//don't dispose the stream
message.BodyStream = stream;
message.Label = toFormat.GetType().AssemblyQualifiedName;
}

What is the format of remote queues' address

From Technet:

Private queues are accessible only by Message Queuing applications
that know the full path name, the direct format name, or
the private format name of the queue, as follows:

* Path name:ComputerName\private$\QueueName.
* Path name on local computer: \private$\QueueName.
* Direct format name:: DIRECT=ComputerAddress\PRIVATE$\PrivateQueueName.
* Private format name: PRIVATE=ComputerGUID\QueueNumber.

See this article for more on queue names. One thing to watch out for is that it's not possible to tell if a remote private queue is transactional or not, and if you post with the wrong transactional option set the message is discarded.

Python pymqi : How to specify the message format for putting to a queue

According to the PyMQI Docs this is the definition of the put call:

put(msg[, mDesc, putOpts])

Put the string buffer ‘msg’ on the queue. If the queue is not already open, it is opened now with the option ‘MQOO_OUTPUT’.

mDesc is the pymqi.md() MQMD Message Descriptor for the message. If it is not passed, or is None, then a default md() object is used.

putOpts is the pymqi.pmo() MQPMO Put Message Options structure for the put call. If it is not passed, or is None, then a default pmo() object is used.

If mDesc and/or putOpts arguments were supplied, they may be updated by the put operation.

So in order to set the format you need to supply an MQMD Message Descriptor, the mDesc parameter on the put call.

I haven't tried this out myself, but your code should look something like:

md = pymqi.MD()
md.Format = CMQC.MQFMT_STRING
putq.put(doc.toprettyxml(), md, None)

Any way to change message format in MQ Console (IBM MQ docker)?

The MQ Console uses the IBM MQ REST API to send messages and is meant more for simple "hello world" testing purposes.

According to the IBM MQ 9.2 Knowledge center page IBM MQ>Reference>Developing applications reference>Messaging REST API reference>REST API resources>/messaging/qmgr/{qmgrName}/queue/{queueName}/message>POST:

Messages are sent as MQSTR formatted messages, and are put using the current user context.

...

Request body format

The request body must be text and use UTF-8 encoding. No specific text structure is required. An MQSTR formatted message containing the request body text is created and put to the specified queue.



Related Topics



Leave a reply



Submit