Publishing and consuming messages from a topic  Chapter 4: Web Services Consumer

Chapter 3: Real Time Messaging Services

Examples

These examples provide a brief preview of the Transact-SQL messaging interface.

Example 1

This example 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

This example 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

This example 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

This example consumes a message from a topic:

select msgconsume('sub1')

Example 5

This example 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 @name=msgpropname(@curr)
select msgproptype(@pname)
select msgpropvalue(@pname)
select @curr=@curr+1
end




Copyright © 2004. Sybase Inc. All rights reserved. Chapter 4: Web Services Consumer

View this book as PDF