What is Topic

A topic consist of name, description, and parameters. The name of the topic is the method in which a topic are retrieve during a subscription while the description and parameters which are optional are used as metadata to help the subscribers reviewing the topic to better understand the purpose of the topic. There two types of topic that can be create which are open and contract based topic.

Contract Topic

This type of topic are one which requires the topic owner to determine what type of information(parameters) will be required before publication occurs. When a topic is setup as a contract based topic, the publisher must include all the expected parameters in order to be able to successfully publish the message to topic. Even though this option restrict message publication to contract, the topic owner can always create another version of the same topic which will include new information as needs change

Open Topic

Unlike contract topic, open topics allows the topic owner to create a topic which is open ended. Meaning that the publisher is allowed to include any parameter they wish when making a publication. The advantage to this method is that the publisher which is most likely the topic owner would be able to change his/her mind about what type of information would be include in the message been published. This method works well when the topic owner has control of both the publisher and the subscriber sides. But it will fail in scenarios where the topic owner is not in control of both sides.

There is two ways to register topics in the ESB. Dynamic and Class based topic creation are the two available options

Dynamic Topic Creation

Dynamic topic allows you to have more control of how you generate topic such as loading topic information from a database or from an xml configuration file. Another advantage of dynamic topic is not restricting the name of your topic and allow you to create topic with special character such as "MyTopic.New" v.s. "MyTopic_New". By using the former, you can take advantage of been able to use subscription that are based on pattern such as "MyTopic.*" which will automatically subscribe the subscriber to any topic that matches the specified condition

An example is as followed below which uses hard-coded value which can easily be modified to be retrieved from any source as needed.

.Description("My Topic Description")
.AddParameter("Param1", "Param1 Description")
.AddParameter("Param2", "Param2 Description")


Class Based Topic Creation

Class based topic are topic which context will be determine by the class name and the description attribute. In this method, the public properties of the class is used as the parameter and the description for each parameter are retrieved from the description attribute of the property if one exists. The description attribute for the class is used to determine to description of the topic been created.

This method of creation is best when you create POCO class that would be used also for publication of message to topics. When using this option it is best to group all Topic classes within the same assembly so as to be able to easily identity all your topics without having to go query the ESB for it.

Example of using class creation below:

[Description("My topic Description")]
public class MyTopic {
	[Description("Param1 Description")]
	public string Param1 { get; set; }
	[Description("Param2 Description")]
	public string Param2 {get; set;}

Last edited Feb 19, 2012 at 7:35 PM by rpgmaker, version 5


No comments yet.