Tuesday, September 29, 2009

EMS: Steps to Send/Receive Message

EMS:  Steps to Send/Receive Message

 

Here are the steps to send/receive message from client side, (java code)

 

  1. Create a connection factory.

 

ConnectonFactory f = new com.tibco.tibjms.TibjmsConnectionFactory(String serverURL);

 

  1. Create a connection

Connection c = f.createConnection(String username, String password);

      If the server property authorization is disabled, you do not need to specify the username and password.

 

  1. Create a session

Session s=c.createSession(Boolean transcationFlag, Int delivery_mode);

 

  1. Get destination

Javax.jms.Queue d=s.CreateQueue(String queueName);

Javax.jms.Topic d=s.CreateTopic(String topicName);

 

Once the Queue/Topic exists, then return the destination object.

 

 

  1. Create message producer to send message, or

MessageProducer p=s.createProducer(Destination  d);

 

Create a Message object, TextMessage object for example,

TextMessage tm = s.createTextMessage();

You can set property for the message and the text body.

tm.setText(String textBody);

tm.setStringProperty(String propertyName, String propertyValue);

p.send(tm);

 

 

  1. Create message consumer to receive message

 MessageConsumer p=s.createConsumer(Destination d, String selector);

     

      For synchronously receiver,

      p.receive();

 

     For asynchronously receiver, you need to implement MessageListener class and restruture the onMessage function.

Class myMessageListener implements MessageListener

{

Public void onMessage(Message message)

{

// add code here to handle if message is sent to queue/topic

   System.out.println(“The imcoming message is: “+message);

}

}

 

     In the main class, set consumer listener

p.setMessageListener(new myMessageListener);

 

Note that, for the MessageConsumer class, you need to start the connection before receive message from Queue/Topic

  1. start();

 

Note: another way to get the ConnectionFactory/Queue/Topic object JNDI interface.

 

 

 

Friday, September 25, 2009

TIBCO EMS: Access Control

TIBCO EMS: Access Control

 

EMS Permissions

  1. administrator permission

The permission defines the right for users/groups to create, modify, delete, and view users, destinations, routes, factories and others.

 

Notes: users in admin group have all administrator permissions regardless of the permission settings.

 

You can not grant revoke administrator permissions from any users in admin group.

Users with change-admin-acl and view-user/group permission can grant or revoke permissions to other users but can only grant or revoke permissions that have been granted.

 

Users in groups inherit the administrator permission.

 

 

  1. destination-based administrator permission

The permission defines the right for users/group to create, modify, delete, purge, view destinations.

Notes:  any destination-lever permission granted to a user or group for a wildcard destination is inherited for all child destinations.

 

  1. user permission

The permission defines the right for users/group to send, receive to/from queue or publish, subscribe to/from topic. Besides, it defines the right to create durable subscriptions to topics.

 

 

Server/Destination Connection Settings

Once the authorization is disabled (default setting), the server grants any connection request and doest not check permissions when a client connects to a destination.

 

Note: users must always log in with the correct administration username and password to perform any administrative function.

 

Once the authorization is enabled, the server grants connections only from authorized users. The server will check the destination permission if the destination has secure property.

 

Note: secure is a destination-based property. The server will not check the destination permission even if the destination permissions have defined but the secure property does not set.

 

Friday, September 18, 2009

TIBCO EMS: Ways to Persistent Message

TIBCO EMS: PERSISTENT MESSAGE

 

  1. Persistent messages sent to Queues

Note: server always persistent the message to disk

 

  1. Persistent messages published to Topics

Note: only persistent the message if the subscribe is one of Durable Consumer or Fault Tolerant Consumer.

 

  1. Persistent Messages and Failsafe Destinations

Note:  once the failsafe in queue or topic are set, the producer or publisher will wait until server persistent the message to disk. Else the server return control to producer or publisher before complete the persistent operations.

TIBCO EMS: Message Delivery Modes

TIBCO EMS: Message Delivery Modes

 

There are 3 types delivery mode in the message which is put into JMSDeliveryMode message header field.

 

  1. PERSISTENT

Note:Server sends confirmation message to producer. The message is persisted on disk by the server.

 

  1. NON_PERSISTENT

Notes: It depends on authorization and npsend_check_mode (defins in file tibemsd.conf)  settings to send confirmation message to producer.

 

  1. RELIABLE_DELIVERY

Note: a extended delivery mode by TIBCO itself. It has the benefit feature of PERSISTET and not its performance issue.

 

Sunday, September 6, 2009

Hello to solve the error -1072896636 when load xml file

I have a xml file which defines a internal DTD to validate its contend and make sure the format is valid.
 
But when I used xmlms 6.0 XML DOM object to load the xml file, the property parseError of the dom object says that there is a parse error. The error code is -1072896636  and its error message is DTD is prohibited.
 
The reason is that later than xmlms 6.0 one property named prohibitDTD's default value is changed to true by default while it was false in previous versions. So before load any xml file with internal DTD, you should remember to set the property to false before proceed to load the xml file.
 
Set xmlDoc = CreateObject("Msxml2.DOMDocument.6.0")
      xmlDoc.setProperty "ProhibitDTD",False
      xmlDoc.load xmltoload.xml
 
..........