These examples provide a brief preview of the Transact-SQL messaging interface.
Example 1 JMS – sends a message to a queue:
select msgsend('hello world', 'tibco_jms:tcp://my_jms_host:7222?queue=queue.sample' message property 'city=Detroit')
Example 2 JMS – reads a message from a queue, with and without a filter:
select msgrecv('tibco_jms:tcp://my_jms_host:7222?queue=queue.sample') select msgrecv ('tibco_jms:tcp://my_jms_host:7222?queue=queue.sample' message selector 'city=''Detroit''')
Example 3 JMS – publishes a message to a topic:
sp_msgadmin register, subscription,sub1, 'tibco_jms:tcp://my_jms_host:7222?topic=topic.sample' select msgpublish ('hello world', 'sub1' message property 'city=Boston')
Example 4 JMS – consumes a message from a topic:
select msgconsume('sub1')
Example 5 JMS – illustrates working with properties:
select msgconsume('sub1') declare @pcount integer declare @curr integer declare @pname varchar(100) select @curr=1 select @pcount = msgpropcount() while(@curr<=@pcount) begin select @pname=msgpropname(@curr) select msgproptype(@pname) select msgpropvalue(@pname) select @curr=@curr+1 end
Example 6 MQSeries – sends a message to a queue:
select msgsend('hello world',� 'ibm_mq:chnl1/tcp/host1(1234)?qmgr=QM,queue=DEFAULT.QUEUE'� message header 'priority=2')�
Example 7 MQSeries – reads a message from a queue:
select msgrecv(� 'ibm_mq:chnl1/tcp/host1(1234)?qmgr=QM,queue=DEFAULT.QUEUE' option 'timeout=30ss')
Example 8 MQSeries – registers a publisher and publishes a message about “fish”:�
select msgsend(NULL,� 'ibm_mq:chnl1/tcp/host1(1234)?qmgr=QM,queue=SYSTEM.BROKER.CONTROL.QUEUE’' option 'rfhCommand=registerPublisher' message header 'topics=fish' + ',streamName=ANIMALS.STREAM')� select msgsend('something about a fish',� 'ibm_mq:chnl1/tcp/host1(1234)?qmgr=QM,queue=ANIMALS.STREAM'� message header 'topics=fish')�
Example 9 MQSeries – registers a subscriber, reads a message, and processes the message properties:
select msgsend(NULL,� 'ibm_mq:chnl1/tcp/host1(1234)?qmgr=QM,queue=SYSTEM.BROKER.CONTROL.QUEUE'� option 'rfhCommand=registerSubscriber' + ',topics=fish'� + ',streamName=ANIMALS.STREAM' + ',queueName=MY_ANIMALS.QUEUE')� select msgrecv(� 'ibm_mq:chnl1/tcp/host1(1234)?qmgr=QM,queue=MY_ANIMALS.QUEUE' option 'timeout=30ss')� select msgpropvalue('MPQScompcode', @@msgproperties)
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |