Working with message properties  Chapter 3: Configuring Real-Time Data Services

Chapter 2: Understanding Real-Time Data Services

Previewing the messaging interface

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

Examples

Example 1 Sends a message to a queue:

select msgsend('hello world',
    'tibco_jms:tcp://my_ems_host:7222?queue=queue.sample',
     MESSAGE PROPERTY 'city=Detroit')

Example 2 Reads a message from a queue, with and without a filter:

select msgrecv('tibco_jms:tcp://my_ems_host:7222?queue=queue.sample')

select msgrecv
     ('tibco_jms:tcp://my_ems_host:7222?queue=queue.sample', 
     MESSAGE SELECTOR 'city=''Detroit''')

Example 3 Publishes a message to a topic:

sp_msgadmin register, subscription,sub1,
     'tibco_jms:tcp://my_ems_host:7222?topic=topic.sample'
select msgpublish
     ('hello world', 'sub1', MESSAGE PROPERTY 'city=Boston')

Example 4 Consumes a message from a topic:

select msgconsume('sub1')

Example 5 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




Copyright © 2005. Sybase Inc. All rights reserved. Chapter 3: Configuring Real-Time Data Services

View this book as PDF