Difference between revisions of "Data Transfer Common Messaging"

From Gcube Wiki
Jump to: navigation, search
(Common Messaging Interface)
m
 
(10 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
<!-- CATEGORIES -->
 +
[[Category:Developer's Guide]]
 +
<!-- END CATEGORIES -->
 
= Common Messaging Interface =
 
= Common Messaging Interface =
 
The Common Messaging Interface has been implemented so that messaging can be integrated from other Components such as scheduler and agent service.
 
The Common Messaging Interface has been implemented so that messaging can be integrated from other Components such as scheduler and agent service.
Line 5: Line 8:
  
 
=== Messages ===
 
=== Messages ===
<br>
+
 
 
*TransferRequestMessage:
 
*TransferRequestMessage:
 
This message holds information about the transfer details that scheduler submits to agent service. Provided information can be input uri's, destination folder, transfer options etc.
 
This message holds information about the transfer details that scheduler submits to agent service. Provided information can be input uri's, destination folder, transfer options etc.
 
*TransferResponseMessage:
 
*TransferResponseMessage:
 
On the other side the transfer response message holds details about the submitted transfer. This message will be sent until the transfer has been completed (whatever that status  will be) and the receiver is able to see the bytes that already have been transferred the status etc.
 
On the other side the transfer response message holds details about the submitted transfer. This message will be sent until the transfer has been completed (whatever that status  will be) and the receiver is able to see the bytes that already have been transferred the status etc.
<br>
+
 
 
=== Messages Queues ===
 
=== Messages Queues ===
TransfeRequest queue specified by the endpoint of the agent destination
+
*TransfeRequest queue specified by the endpoint of the agent destination
TransferResponse queue  
+
*TransferResponse queue  
<br>
+
 
 
=== Scenario ===
 
=== Scenario ===
<br>
+
 
Just to give a initial overview of the API the following is a simple code snippet which initialize a MSGClient used both in agent and scheduler service for producing a message.  
+
Just to give a initial overview of the API the following is a simple code snippet which initialize an MSGClient used both in agent and scheduler service for producing a message.  
  
 
<source lang="java5">
 
<source lang="java5">
Line 23: Line 26:
 
ScopeProvider.instance.set(scope.toString());
 
ScopeProvider.instance.set(scope.toString());
 
try {
 
try {
ServiceContext.getContext().setMsgClient(MSGClientFactory.getMSGClientInstance());
+
msgClient = MSGClientFactory.getMSGClientInstance();
 
} catch (Exception e) {
 
} catch (Exception e) {
 
e.printStackTrace();
 
e.printStackTrace();
Line 29: Line 32:
 
</source>
 
</source>
  
For the subscription, the scheduler and agent should follow respectively the following:  
+
For the subscription, the scheduler and agent should follow respectively the following
 +
(where sourceEndpoint is the subscriber's endpoint):  
 
<source lang="java5">
 
<source lang="java5">
// **** Scheduler Ssubscription ****
+
// **** Scheduler Subscription ****
 
TransferResponseSubscription subscriber = new TransferResponseSubscription(sourceEndpoint);
 
TransferResponseSubscription subscriber = new TransferResponseSubscription(sourceEndpoint);
 
subscriber.setScope(scope);
 
subscriber.setScope(scope);
Line 40: Line 44:
 
}
 
}
  
// **** Agent Ssubscription ****
+
// **** Agent Subscription ****
 
TransferRequestSubscription subscriber = new TransferRequestSubscription(sourceEndpoint);
 
TransferRequestSubscription subscriber = new TransferRequestSubscription(sourceEndpoint);
 
subscriber.setScope(scope);
 
subscriber.setScope(scope);
Line 46: Line 50:
 
subscriber.subscribe();
 
subscriber.subscribe();
 
} catch (Exception e) {
 
} catch (Exception e) {
 +
e.printStackTrace();
 +
}
 +
</source>
 +
 +
For producing a message:
 +
<source lang="java5">
 +
TransferRequestMessage transferRequestMessage = new TransferRequestMessage();
 +
//transferRequestMessage.set blah blah... set all the appropriate info
 +
//...
 +
transferRequestMessage.createTopicNname(scope);
 +
// **** Send a request message ****
 +
try {
 +
msgClient.sendRequestMessage(context, transferRequestMessage, scope);
 +
}catch (Exception e) {
 
e.printStackTrace();
 
e.printStackTrace();
 
}
 
}
 
</source>
 
</source>

Latest revision as of 18:46, 11 July 2013

Common Messaging Interface

The Common Messaging Interface has been implemented so that messaging can be integrated from other Components such as scheduler and agent service.

Common Messaging

Messages

  • TransferRequestMessage:

This message holds information about the transfer details that scheduler submits to agent service. Provided information can be input uri's, destination folder, transfer options etc.

  • TransferResponseMessage:

On the other side the transfer response message holds details about the submitted transfer. This message will be sent until the transfer has been completed (whatever that status will be) and the receiver is able to see the bytes that already have been transferred the status etc.

Messages Queues

  • TransfeRequest queue specified by the endpoint of the agent destination
  • TransferResponse queue

Scenario

Just to give a initial overview of the API the following is a simple code snippet which initialize an MSGClient used both in agent and scheduler service for producing a message.

// **** Setting MSG Client ****
ScopeProvider.instance.set(scope.toString());
try {
	msgClient = MSGClientFactory.getMSGClientInstance();
} catch (Exception e) {
	e.printStackTrace();
}

For the subscription, the scheduler and agent should follow respectively the following (where sourceEndpoint is the subscriber's endpoint):

// **** Scheduler Subscription ****
TransferResponseSubscription subscriber = new TransferResponseSubscription(sourceEndpoint);
subscriber.setScope(scope);
try {
	subscriber.subscribe();
} catch (Exception e) {
	e.printStackTrace();
}			
 
// **** Agent Subscription ****
TransferRequestSubscription subscriber = new TransferRequestSubscription(sourceEndpoint);
subscriber.setScope(scope);
try {
	subscriber.subscribe();
} catch (Exception e) {
	e.printStackTrace();
}

For producing a message:

TransferRequestMessage transferRequestMessage = new TransferRequestMessage();
//transferRequestMessage.set blah blah... set all the appropriate info
//...
transferRequestMessage.createTopicNname(scope);
// **** Send a request message ****
try {
	msgClient.sendRequestMessage(context, transferRequestMessage, scope);
}catch (Exception e) {
	e.printStackTrace();
}