mirror of https://github.com/apache/activemq.git
working OpenWire.Net client! While not all of JMS is supported just yet, the test program shows the creation of a Connection, Session, Consumer, Producer and sending and receiving a message (using the synchronous dispatch)
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@380220 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2ce853a42d
commit
33094e694a
|
@ -36,10 +36,12 @@ namespace OpenWire.Client.Commands
|
||||||
public const byte ID_ActiveMQObjectMessage = 26;
|
public const byte ID_ActiveMQObjectMessage = 26;
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -4,17 +4,21 @@ using System.Collections;
|
||||||
using OpenWire.Client;
|
using OpenWire.Client;
|
||||||
using OpenWire.Client.Core;
|
using OpenWire.Client.Core;
|
||||||
|
|
||||||
namespace OpenWire.Client.Commands {
|
namespace OpenWire.Client.Commands
|
||||||
public class ActiveMQTextMessage : ActiveMQMessage, ITextMessage {
|
{
|
||||||
|
public class ActiveMQTextMessage : ActiveMQMessage, ITextMessage
|
||||||
|
{
|
||||||
public const byte ID_ActiveMQTextMessage = 28;
|
public const byte ID_ActiveMQTextMessage = 28;
|
||||||
|
|
||||||
private String text;
|
private String text;
|
||||||
|
|
||||||
public ActiveMQTextMessage() {
|
public ActiveMQTextMessage()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActiveMQTextMessage(String text) {
|
public ActiveMQTextMessage(String text)
|
||||||
this.text = text;
|
{
|
||||||
|
this.Text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
// TODO generate Equals method
|
||||||
|
@ -22,21 +26,53 @@ namespace OpenWire.Client.Commands {
|
||||||
// TODO generate ToString method
|
// TODO generate ToString method
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType()
|
||||||
|
{
|
||||||
return ID_ActiveMQTextMessage;
|
return ID_ActiveMQTextMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
|
|
||||||
public string Text {
|
public string Text
|
||||||
|
{
|
||||||
get {
|
get {
|
||||||
if (text == null) {
|
if (text == null)
|
||||||
// TODO parse from the content
|
{
|
||||||
|
// now lets read the content
|
||||||
|
|
||||||
|
byte[] data = this.Content;
|
||||||
|
if (data != null)
|
||||||
|
{
|
||||||
|
// TODO assume that the text is ASCII
|
||||||
|
char[] chars = new char[data.Length];
|
||||||
|
for (int i = 0; i < chars.Length; i++)
|
||||||
|
{
|
||||||
|
chars[i] = (char) data[i];
|
||||||
|
}
|
||||||
|
text = new String(chars);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
set { this.text = value; }
|
|
||||||
|
set {
|
||||||
|
this.text = value;
|
||||||
|
byte[] data = null;
|
||||||
|
if (text != null)
|
||||||
|
{
|
||||||
|
// TODO assume that the text is ASCII
|
||||||
|
data = new byte[text.Length];
|
||||||
|
|
||||||
|
// now lets write the bytes
|
||||||
|
char[] chars = text.ToCharArray();
|
||||||
|
for (int i = 0; i < chars.Length; i++)
|
||||||
|
{
|
||||||
|
data[i] = (byte) chars[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.Content = data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,35 @@ namespace OpenWire.Client.Commands
|
||||||
|
|
||||||
string value;
|
string value;
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int answer = 0;
|
||||||
|
answer = (answer * 37) + HashCode(Value);
|
||||||
|
return answer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool Equals(object that) {
|
||||||
|
if (that is BrokerId) {
|
||||||
|
return Equals((BrokerId) that);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Equals(BrokerId that) {
|
||||||
|
if (! Equals(this.Value, that.Value)) return false;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Value=" + Value
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -41,10 +41,17 @@ namespace OpenWire.Client.Commands
|
||||||
string brokerName;
|
string brokerName;
|
||||||
bool slaveBroker;
|
bool slaveBroker;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " BrokerId=" + BrokerId
|
||||||
|
+ " BrokerURL=" + BrokerURL
|
||||||
|
+ " PeerBrokerInfos=" + PeerBrokerInfos
|
||||||
|
+ " BrokerName=" + BrokerName
|
||||||
|
+ " SlaveBroker=" + SlaveBroker
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -38,10 +38,14 @@ namespace OpenWire.Client.Commands
|
||||||
BrokerError exception;
|
BrokerError exception;
|
||||||
ConnectionId connectionId;
|
ConnectionId connectionId;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Exception=" + Exception
|
||||||
|
+ " ConnectionId=" + ConnectionId
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -37,10 +37,35 @@ namespace OpenWire.Client.Commands
|
||||||
|
|
||||||
string value;
|
string value;
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int answer = 0;
|
||||||
|
answer = (answer * 37) + HashCode(Value);
|
||||||
|
return answer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool Equals(object that) {
|
||||||
|
if (that is ConnectionId) {
|
||||||
|
return Equals((ConnectionId) that);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Equals(ConnectionId that) {
|
||||||
|
if (! Equals(this.Value, that.Value)) return false;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Value=" + Value
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -41,10 +41,17 @@ namespace OpenWire.Client.Commands
|
||||||
string userName;
|
string userName;
|
||||||
BrokerId[] brokerPath;
|
BrokerId[] brokerPath;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ConnectionId=" + ConnectionId
|
||||||
|
+ " ClientId=" + ClientId
|
||||||
|
+ " Password=" + Password
|
||||||
|
+ " UserName=" + UserName
|
||||||
|
+ " BrokerPath=" + BrokerPath
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -39,10 +39,41 @@ namespace OpenWire.Client.Commands
|
||||||
long sessionId;
|
long sessionId;
|
||||||
long value;
|
long value;
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int answer = 0;
|
||||||
|
answer = (answer * 37) + HashCode(ConnectionId);
|
||||||
|
answer = (answer * 37) + HashCode(SessionId);
|
||||||
|
answer = (answer * 37) + HashCode(Value);
|
||||||
|
return answer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool Equals(object that) {
|
||||||
|
if (that is ConsumerId) {
|
||||||
|
return Equals((ConsumerId) that);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Equals(ConsumerId that) {
|
||||||
|
if (! Equals(this.ConnectionId, that.ConnectionId)) return false;
|
||||||
|
if (! Equals(this.SessionId, that.SessionId)) return false;
|
||||||
|
if (! Equals(this.Value, that.Value)) return false;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ConnectionId=" + ConnectionId
|
||||||
|
+ " SessionId=" + SessionId
|
||||||
|
+ " Value=" + Value
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -49,10 +49,25 @@ namespace OpenWire.Client.Commands
|
||||||
BrokerId[] brokerPath;
|
BrokerId[] brokerPath;
|
||||||
bool networkSubscription;
|
bool networkSubscription;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ConsumerId=" + ConsumerId
|
||||||
|
+ " Browser=" + Browser
|
||||||
|
+ " Destination=" + Destination
|
||||||
|
+ " PrefetchSize=" + PrefetchSize
|
||||||
|
+ " DispatchAsync=" + DispatchAsync
|
||||||
|
+ " Selector=" + Selector
|
||||||
|
+ " SubcriptionName=" + SubcriptionName
|
||||||
|
+ " NoLocal=" + NoLocal
|
||||||
|
+ " Exclusive=" + Exclusive
|
||||||
|
+ " Retroactive=" + Retroactive
|
||||||
|
+ " Priority=" + Priority
|
||||||
|
+ " BrokerPath=" + BrokerPath
|
||||||
|
+ " NetworkSubscription=" + NetworkSubscription
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -37,10 +37,13 @@ namespace OpenWire.Client.Commands
|
||||||
|
|
||||||
string command;
|
string command;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Command=" + Command
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -37,10 +37,13 @@ namespace OpenWire.Client.Commands
|
||||||
|
|
||||||
DataStructure[] data;
|
DataStructure[] data;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Data=" + Data
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -37,10 +37,13 @@ namespace OpenWire.Client.Commands
|
||||||
|
|
||||||
DataStructure data;
|
DataStructure data;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Data=" + Data
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -41,10 +41,17 @@ namespace OpenWire.Client.Commands
|
||||||
long timeout;
|
long timeout;
|
||||||
BrokerId[] brokerPath;
|
BrokerId[] brokerPath;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ConnectionId=" + ConnectionId
|
||||||
|
+ " Destination=" + Destination
|
||||||
|
+ " OperationType=" + OperationType
|
||||||
|
+ " Timeout=" + Timeout
|
||||||
|
+ " BrokerPath=" + BrokerPath
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -38,10 +38,14 @@ namespace OpenWire.Client.Commands
|
||||||
string serviceName;
|
string serviceName;
|
||||||
string brokerName;
|
string brokerName;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ServiceName=" + ServiceName
|
||||||
|
+ " BrokerName=" + BrokerName
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -37,10 +37,13 @@ namespace OpenWire.Client.Commands
|
||||||
|
|
||||||
BrokerError exception;
|
BrokerError exception;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Exception=" + Exception
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -36,10 +36,12 @@ namespace OpenWire.Client.Commands
|
||||||
public const byte ID_FlushCommand = 15;
|
public const byte ID_FlushCommand = 15;
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -37,10 +37,13 @@ namespace OpenWire.Client.Commands
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Result=" + Result
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -38,10 +38,14 @@ namespace OpenWire.Client.Commands
|
||||||
ActiveMQDestination destination;
|
ActiveMQDestination destination;
|
||||||
MessageAck messageAck;
|
MessageAck messageAck;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Destination=" + Destination
|
||||||
|
+ " MessageAck=" + MessageAck
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -42,10 +42,18 @@ namespace OpenWire.Client.Commands
|
||||||
string clientId;
|
string clientId;
|
||||||
TransactionId transactionId;
|
TransactionId transactionId;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Destination=" + Destination
|
||||||
|
+ " MessageId=" + MessageId
|
||||||
|
+ " MessageSequenceId=" + MessageSequenceId
|
||||||
|
+ " SubscritionName=" + SubscritionName
|
||||||
|
+ " ClientId=" + ClientId
|
||||||
|
+ " TransactionId=" + TransactionId
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -37,10 +37,13 @@ namespace OpenWire.Client.Commands
|
||||||
|
|
||||||
string message;
|
string message;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Message=" + Message
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -39,10 +39,15 @@ namespace OpenWire.Client.Commands
|
||||||
byte type;
|
byte type;
|
||||||
bool wasPrepared;
|
bool wasPrepared;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " TransactionId=" + TransactionId
|
||||||
|
+ " Type=" + Type
|
||||||
|
+ " WasPrepared=" + WasPrepared
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -36,10 +36,12 @@ namespace OpenWire.Client.Commands
|
||||||
public const byte ID_KeepAliveInfo = 10;
|
public const byte ID_KeepAliveInfo = 10;
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -38,10 +38,38 @@ namespace OpenWire.Client.Commands
|
||||||
long value;
|
long value;
|
||||||
ConnectionId connectionId;
|
ConnectionId connectionId;
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int answer = 0;
|
||||||
|
answer = (answer * 37) + HashCode(Value);
|
||||||
|
answer = (answer * 37) + HashCode(ConnectionId);
|
||||||
|
return answer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool Equals(object that) {
|
||||||
|
if (that is LocalTransactionId) {
|
||||||
|
return Equals((LocalTransactionId) that);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Equals(LocalTransactionId that) {
|
||||||
|
if (! Equals(this.Value, that.Value)) return false;
|
||||||
|
if (! Equals(this.ConnectionId, that.ConnectionId)) return false;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Value=" + Value
|
||||||
|
+ " ConnectionId=" + ConnectionId
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -61,10 +61,37 @@ namespace OpenWire.Client.Commands
|
||||||
string userID;
|
string userID;
|
||||||
bool recievedByDFBridge;
|
bool recievedByDFBridge;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ProducerId=" + ProducerId
|
||||||
|
+ " Destination=" + Destination
|
||||||
|
+ " TransactionId=" + TransactionId
|
||||||
|
+ " OriginalDestination=" + OriginalDestination
|
||||||
|
+ " MessageId=" + MessageId
|
||||||
|
+ " OriginalTransactionId=" + OriginalTransactionId
|
||||||
|
+ " GroupID=" + GroupID
|
||||||
|
+ " GroupSequence=" + GroupSequence
|
||||||
|
+ " CorrelationId=" + CorrelationId
|
||||||
|
+ " Persistent=" + Persistent
|
||||||
|
+ " Expiration=" + Expiration
|
||||||
|
+ " Priority=" + Priority
|
||||||
|
+ " ReplyTo=" + ReplyTo
|
||||||
|
+ " Timestamp=" + Timestamp
|
||||||
|
+ " Type=" + Type
|
||||||
|
+ " Content=" + Content
|
||||||
|
+ " MarshalledProperties=" + MarshalledProperties
|
||||||
|
+ " DataStructure=" + DataStructure
|
||||||
|
+ " TargetConsumerId=" + TargetConsumerId
|
||||||
|
+ " Compressed=" + Compressed
|
||||||
|
+ " RedeliveryCounter=" + RedeliveryCounter
|
||||||
|
+ " BrokerPath=" + BrokerPath
|
||||||
|
+ " Arrival=" + Arrival
|
||||||
|
+ " UserID=" + UserID
|
||||||
|
+ " RecievedByDFBridge=" + RecievedByDFBridge
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -43,10 +43,19 @@ namespace OpenWire.Client.Commands
|
||||||
MessageId lastMessageId;
|
MessageId lastMessageId;
|
||||||
int messageCount;
|
int messageCount;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Destination=" + Destination
|
||||||
|
+ " TransactionId=" + TransactionId
|
||||||
|
+ " ConsumerId=" + ConsumerId
|
||||||
|
+ " AckType=" + AckType
|
||||||
|
+ " FirstMessageId=" + FirstMessageId
|
||||||
|
+ " LastMessageId=" + LastMessageId
|
||||||
|
+ " MessageCount=" + MessageCount
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -40,10 +40,16 @@ namespace OpenWire.Client.Commands
|
||||||
Message message;
|
Message message;
|
||||||
int redeliveryCounter;
|
int redeliveryCounter;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ConsumerId=" + ConsumerId
|
||||||
|
+ " Destination=" + Destination
|
||||||
|
+ " Message=" + Message
|
||||||
|
+ " RedeliveryCounter=" + RedeliveryCounter
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -40,10 +40,16 @@ namespace OpenWire.Client.Commands
|
||||||
long deliverySequenceId;
|
long deliverySequenceId;
|
||||||
MessageId messageId;
|
MessageId messageId;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ConsumerId=" + ConsumerId
|
||||||
|
+ " Destination=" + Destination
|
||||||
|
+ " DeliverySequenceId=" + DeliverySequenceId
|
||||||
|
+ " MessageId=" + MessageId
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -39,10 +39,41 @@ namespace OpenWire.Client.Commands
|
||||||
long producerSequenceId;
|
long producerSequenceId;
|
||||||
long brokerSequenceId;
|
long brokerSequenceId;
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int answer = 0;
|
||||||
|
answer = (answer * 37) + HashCode(ProducerId);
|
||||||
|
answer = (answer * 37) + HashCode(ProducerSequenceId);
|
||||||
|
answer = (answer * 37) + HashCode(BrokerSequenceId);
|
||||||
|
return answer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool Equals(object that) {
|
||||||
|
if (that is MessageId) {
|
||||||
|
return Equals((MessageId) that);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Equals(MessageId that) {
|
||||||
|
if (! Equals(this.ProducerId, that.ProducerId)) return false;
|
||||||
|
if (! Equals(this.ProducerSequenceId, that.ProducerSequenceId)) return false;
|
||||||
|
if (! Equals(this.BrokerSequenceId, that.BrokerSequenceId)) return false;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ProducerId=" + ProducerId
|
||||||
|
+ " ProducerSequenceId=" + ProducerSequenceId
|
||||||
|
+ " BrokerSequenceId=" + BrokerSequenceId
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -39,10 +39,41 @@ namespace OpenWire.Client.Commands
|
||||||
long value;
|
long value;
|
||||||
long sessionId;
|
long sessionId;
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int answer = 0;
|
||||||
|
answer = (answer * 37) + HashCode(ConnectionId);
|
||||||
|
answer = (answer * 37) + HashCode(Value);
|
||||||
|
answer = (answer * 37) + HashCode(SessionId);
|
||||||
|
return answer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool Equals(object that) {
|
||||||
|
if (that is ProducerId) {
|
||||||
|
return Equals((ProducerId) that);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Equals(ProducerId that) {
|
||||||
|
if (! Equals(this.ConnectionId, that.ConnectionId)) return false;
|
||||||
|
if (! Equals(this.Value, that.Value)) return false;
|
||||||
|
if (! Equals(this.SessionId, that.SessionId)) return false;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ConnectionId=" + ConnectionId
|
||||||
|
+ " Value=" + Value
|
||||||
|
+ " SessionId=" + SessionId
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -39,10 +39,15 @@ namespace OpenWire.Client.Commands
|
||||||
ActiveMQDestination destination;
|
ActiveMQDestination destination;
|
||||||
BrokerId[] brokerPath;
|
BrokerId[] brokerPath;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ProducerId=" + ProducerId
|
||||||
|
+ " Destination=" + Destination
|
||||||
|
+ " BrokerPath=" + BrokerPath
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -37,10 +37,13 @@ namespace OpenWire.Client.Commands
|
||||||
|
|
||||||
DataStructure objectId;
|
DataStructure objectId;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ObjectId=" + ObjectId
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -39,10 +39,15 @@ namespace OpenWire.Client.Commands
|
||||||
string subcriptionName;
|
string subcriptionName;
|
||||||
string clientId;
|
string clientId;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ConnectionId=" + ConnectionId
|
||||||
|
+ " SubcriptionName=" + SubcriptionName
|
||||||
|
+ " ClientId=" + ClientId
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -37,10 +37,13 @@ namespace OpenWire.Client.Commands
|
||||||
|
|
||||||
short correlationId;
|
short correlationId;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " CorrelationId=" + CorrelationId
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -38,10 +38,38 @@ namespace OpenWire.Client.Commands
|
||||||
string connectionId;
|
string connectionId;
|
||||||
long value;
|
long value;
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int answer = 0;
|
||||||
|
answer = (answer * 37) + HashCode(ConnectionId);
|
||||||
|
answer = (answer * 37) + HashCode(Value);
|
||||||
|
return answer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool Equals(object that) {
|
||||||
|
if (that is SessionId) {
|
||||||
|
return Equals((SessionId) that);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Equals(SessionId that) {
|
||||||
|
if (! Equals(this.ConnectionId, that.ConnectionId)) return false;
|
||||||
|
if (! Equals(this.Value, that.Value)) return false;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ConnectionId=" + ConnectionId
|
||||||
|
+ " Value=" + Value
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -37,10 +37,13 @@ namespace OpenWire.Client.Commands
|
||||||
|
|
||||||
SessionId sessionId;
|
SessionId sessionId;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " SessionId=" + SessionId
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -36,10 +36,12 @@ namespace OpenWire.Client.Commands
|
||||||
public const byte ID_ShutdownInfo = 11;
|
public const byte ID_ShutdownInfo = 11;
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -40,10 +40,16 @@ namespace OpenWire.Client.Commands
|
||||||
string selector;
|
string selector;
|
||||||
string subcriptionName;
|
string subcriptionName;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ClientId=" + ClientId
|
||||||
|
+ " Destination=" + Destination
|
||||||
|
+ " Selector=" + Selector
|
||||||
|
+ " SubcriptionName=" + SubcriptionName
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -36,10 +36,32 @@ namespace OpenWire.Client.Commands
|
||||||
public const byte ID_TransactionId = 0;
|
public const byte ID_TransactionId = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int answer = 0;
|
||||||
|
return answer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool Equals(object that) {
|
||||||
|
if (that is TransactionId) {
|
||||||
|
return Equals((TransactionId) that);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Equals(TransactionId that) {
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -39,10 +39,15 @@ namespace OpenWire.Client.Commands
|
||||||
TransactionId transactionId;
|
TransactionId transactionId;
|
||||||
byte type;
|
byte type;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " ConnectionId=" + ConnectionId
|
||||||
|
+ " TransactionId=" + TransactionId
|
||||||
|
+ " Type=" + Type
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -39,10 +39,15 @@ namespace OpenWire.Client.Commands
|
||||||
int version;
|
int version;
|
||||||
int options;
|
int options;
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " Magic=" + Magic
|
||||||
|
+ " Version=" + Version
|
||||||
|
+ " Options=" + Options
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -39,10 +39,41 @@ namespace OpenWire.Client.Commands
|
||||||
byte[] globalTransactionId;
|
byte[] globalTransactionId;
|
||||||
byte[] branchQualifier;
|
byte[] branchQualifier;
|
||||||
|
|
||||||
|
public override int GetHashCode() {
|
||||||
|
int answer = 0;
|
||||||
|
answer = (answer * 37) + HashCode(FormatId);
|
||||||
|
answer = (answer * 37) + HashCode(GlobalTransactionId);
|
||||||
|
answer = (answer * 37) + HashCode(BranchQualifier);
|
||||||
|
return answer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool Equals(object that) {
|
||||||
|
if (that is XATransactionId) {
|
||||||
|
return Equals((XATransactionId) that);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool Equals(XATransactionId that) {
|
||||||
|
if (! Equals(this.FormatId, that.FormatId)) return false;
|
||||||
|
if (! Equals(this.GlobalTransactionId, that.GlobalTransactionId)) return false;
|
||||||
|
if (! Equals(this.BranchQualifier, that.BranchQualifier)) return false;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override string ToString() {
|
||||||
|
return GetType().Name + "["
|
||||||
|
+ " FormatId=" + FormatId
|
||||||
|
+ " GlobalTransactionId=" + GlobalTransactionId
|
||||||
|
+ " BranchQualifier=" + BranchQualifier
|
||||||
|
+ " ]";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO generate Equals method
|
|
||||||
// TODO generate GetHashCode method
|
|
||||||
// TODO generate ToString method
|
|
||||||
|
|
||||||
|
|
||||||
public override byte GetDataStructureType() {
|
public override byte GetDataStructureType() {
|
||||||
|
|
|
@ -15,13 +15,15 @@ namespace OpenWire.Client
|
||||||
private ITransport transport;
|
private ITransport transport;
|
||||||
private ConnectionInfo info;
|
private ConnectionInfo info;
|
||||||
private WireFormatInfo wireFormatInfo = new WireFormatInfo();
|
private WireFormatInfo wireFormatInfo = new WireFormatInfo();
|
||||||
IList sessions = new ArrayList();
|
private BrokerInfo brokerInfo; // from broker
|
||||||
|
private WireFormatInfo brokerWireFormatInfo; // from broker
|
||||||
|
private IList sessions = new ArrayList();
|
||||||
private bool transacted;
|
private bool transacted;
|
||||||
private bool connected;
|
private bool connected;
|
||||||
private bool closed;
|
private bool closed;
|
||||||
private AcknowledgementMode acknowledgementMode;
|
private AcknowledgementMode acknowledgementMode;
|
||||||
private long sessionCounter;
|
private long sessionCounter;
|
||||||
private IDictionary consumers = new Hashtable(); // TODO threadsafe
|
private IDictionary consumers = new Hashtable();// TODO threadsafe
|
||||||
|
|
||||||
|
|
||||||
public Connection(ITransport transport, ConnectionInfo info)
|
public Connection(ITransport transport, ConnectionInfo info)
|
||||||
|
@ -29,6 +31,7 @@ namespace OpenWire.Client
|
||||||
this.transport = transport;
|
this.transport = transport;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.transport.Command += new CommandHandler(OnCommand);
|
this.transport.Command += new CommandHandler(OnCommand);
|
||||||
|
this.transport.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,18 +138,13 @@ namespace OpenWire.Client
|
||||||
}
|
}
|
||||||
if (!connected)
|
if (!connected)
|
||||||
{
|
{
|
||||||
Console.WriteLine("ConnectionId: " + info.ConnectionId.Value);
|
|
||||||
Console.WriteLine("ClientID: " + info.ClientId);
|
|
||||||
|
|
||||||
Console.WriteLine("About to send WireFormatInfo: " + wireFormatInfo);
|
|
||||||
// lets configure the wire format
|
// lets configure the wire format
|
||||||
wireFormatInfo.Magic = CreateMagicBytes();
|
wireFormatInfo.Magic = CreateMagicBytes();
|
||||||
wireFormatInfo.Version = 1;
|
wireFormatInfo.Version = 1;
|
||||||
transport.Oneway(wireFormatInfo);
|
transport.Oneway(wireFormatInfo);
|
||||||
|
|
||||||
Console.WriteLine("About to send ConnectionInfo: " + info);
|
// now lets send the connection and see if we get an ack/nak
|
||||||
SyncRequest(info);
|
SyncRequest(info);
|
||||||
Console.WriteLine("Received connection info response");
|
|
||||||
connected = true;
|
connected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,7 +156,6 @@ namespace OpenWire.Client
|
||||||
/// <param name="consumer">A MessageConsumer</param>
|
/// <param name="consumer">A MessageConsumer</param>
|
||||||
public void AddConsumer(ConsumerId consumerId, MessageConsumer consumer)
|
public void AddConsumer(ConsumerId consumerId, MessageConsumer consumer)
|
||||||
{
|
{
|
||||||
Console.WriteLine("#### Adding consumerId: " + consumerId.Value + " session: " + consumerId.SessionId + " with consumer: " + consumer);
|
|
||||||
consumers[consumerId] = consumer;
|
consumers[consumerId] = consumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,22 +177,30 @@ namespace OpenWire.Client
|
||||||
/// <param name="command">A Command</param>
|
/// <param name="command">A Command</param>
|
||||||
protected void OnCommand(ITransport transport, Command command)
|
protected void OnCommand(ITransport transport, Command command)
|
||||||
{
|
{
|
||||||
if (command is MessageDispatch) {
|
if (command is MessageDispatch)
|
||||||
|
{
|
||||||
MessageDispatch dispatch = (MessageDispatch) command;
|
MessageDispatch dispatch = (MessageDispatch) command;
|
||||||
ConsumerId consumerId = dispatch.ConsumerId;
|
ConsumerId consumerId = dispatch.ConsumerId;
|
||||||
MessageConsumer consumer = (MessageConsumer) consumers[consumerId];
|
MessageConsumer consumer = (MessageConsumer) consumers[consumerId];
|
||||||
if (consumer == null) {
|
if (consumer == null)
|
||||||
Console.WriteLine("No such consumer active: " + consumerId);
|
{
|
||||||
Console.WriteLine("No such consumer active: " + consumerId.Value);
|
Console.WriteLine("ERROR: No such consumer active: " + consumerId);
|
||||||
Console.WriteLine("No such consumer active: " + consumerId.SessionId);
|
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
ActiveMQMessage message = (ActiveMQMessage) dispatch.Message;
|
ActiveMQMessage message = (ActiveMQMessage) dispatch.Message;
|
||||||
consumer.Dispatch(message);
|
consumer.Dispatch(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (command is WireFormatInfo) {
|
||||||
Console.WriteLine("Unknown command: " + command);
|
this.brokerWireFormatInfo = (WireFormatInfo) command;
|
||||||
|
}
|
||||||
|
else if (command is BrokerInfo) {
|
||||||
|
this.brokerInfo = (BrokerInfo) command;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("ERROR:ÊUnknown command: " + command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace OpenWire.Client
|
||||||
|
|
||||||
// Implementation methods
|
// Implementation methods
|
||||||
|
|
||||||
protected ConnectionInfo CreateConnectionInfo(string userName, string password)
|
protected virtual ConnectionInfo CreateConnectionInfo(string userName, string password)
|
||||||
{
|
{
|
||||||
ConnectionInfo answer = new ConnectionInfo();
|
ConnectionInfo answer = new ConnectionInfo();
|
||||||
ConnectionId connectionId = new ConnectionId();
|
ConnectionId connectionId = new ConnectionId();
|
||||||
|
|
|
@ -109,5 +109,18 @@ namespace OpenWire.Client.Core
|
||||||
}
|
}
|
||||||
return packetTypeStr;
|
return packetTypeStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Helper methods
|
||||||
|
public int HashCode(object value)
|
||||||
|
{
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
return value.GetHashCode();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
using System.Collections;
|
||||||
|
using OpenWire.Client.Commands;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace OpenWire.Client
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the multi-threaded dispatching between the transport and the consumers
|
||||||
|
/// </summary>
|
||||||
|
public class Dispatcher
|
||||||
|
{
|
||||||
|
Queue queue = Queue.Synchronized( new Queue() );
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method Enqueue
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message">An ActiveMQMessage</param>
|
||||||
|
public void Enqueue(ActiveMQMessage message)
|
||||||
|
{
|
||||||
|
queue.Enqueue(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method DequeueNoWait
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An IMessage</retutns>
|
||||||
|
public IMessage DequeueNoWait()
|
||||||
|
{
|
||||||
|
lock (queue) {
|
||||||
|
if (queue.Peek() != null) {
|
||||||
|
return (IMessage) queue.Dequeue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method Dequeue
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="timeout">A long</param>
|
||||||
|
/// <returns>An IMessage</retutns>
|
||||||
|
public IMessage Dequeue(long timeout)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
throw new Exception("Not implemented yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method Dequeue
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>An IMessage</retutns>
|
||||||
|
public IMessage Dequeue()
|
||||||
|
{
|
||||||
|
return (IMessage) queue.Dequeue();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,8 @@ using OpenWire.Client;
|
||||||
using OpenWire.Client.Commands;
|
using OpenWire.Client.Commands;
|
||||||
using OpenWire.Client.Core;
|
using OpenWire.Client.Core;
|
||||||
|
|
||||||
namespace OpenWire.Client.Core {
|
namespace OpenWire.Client.Core
|
||||||
|
{
|
||||||
|
|
||||||
public delegate void CommandHandler(ITransport sender, Command command);
|
public delegate void CommandHandler(ITransport sender, Command command);
|
||||||
public delegate void ExceptionHandler(ITransport sender, Exception command);
|
public delegate void ExceptionHandler(ITransport sender, Exception command);
|
||||||
|
@ -12,7 +13,8 @@ namespace OpenWire.Client.Core {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the logical networking transport layer.
|
/// Represents the logical networking transport layer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ITransport : IDisposable {
|
public interface ITransport : IStartable, IDisposable
|
||||||
|
{
|
||||||
void Oneway(Command command);
|
void Oneway(Command command);
|
||||||
|
|
||||||
FutureResponse AsyncRequest(Command command);
|
FutureResponse AsyncRequest(Command command);
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace OpenWire.Client.Core
|
||||||
DataStreamMarshaller dsm = (DataStreamMarshaller) dataMarshallers[dataType & 0xFF];
|
DataStreamMarshaller dsm = (DataStreamMarshaller) dataMarshallers[dataType & 0xFF];
|
||||||
if (dsm == null)
|
if (dsm == null)
|
||||||
throw new IOException("Unknown data type: " + dataType);
|
throw new IOException("Unknown data type: " + dataType);
|
||||||
Console.WriteLine("Parsing type: " + dataType + " with: " + dsm);
|
//Console.WriteLine("Parsing type: " + dataType + " with: " + dsm);
|
||||||
Object data = dsm.CreateObject();
|
Object data = dsm.CreateObject();
|
||||||
BooleanStream bs = new BooleanStream();
|
BooleanStream bs = new BooleanStream();
|
||||||
bs.Unmarshal(dis);
|
bs.Unmarshal(dis);
|
||||||
|
@ -102,7 +102,7 @@ namespace OpenWire.Client.Core
|
||||||
DataStreamMarshaller dsm = (DataStreamMarshaller) dataMarshallers[type & 0xFF];
|
DataStreamMarshaller dsm = (DataStreamMarshaller) dataMarshallers[type & 0xFF];
|
||||||
if (dsm == null)
|
if (dsm == null)
|
||||||
throw new IOException("Unknown data type: " + type);
|
throw new IOException("Unknown data type: " + type);
|
||||||
Console.WriteLine("Marshalling type: " + type + " with structure: " + o);
|
//Console.WriteLine("Marshalling type: " + type + " with structure: " + o);
|
||||||
return 1 + dsm.Marshal1(this, o, bs);
|
return 1 + dsm.Marshal1(this, o, bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,22 +21,36 @@ namespace OpenWire.Client.Core
|
||||||
public class SocketTransport : ITransport
|
public class SocketTransport : ITransport
|
||||||
{
|
{
|
||||||
private readonly object transmissionLock = new object();
|
private readonly object transmissionLock = new object();
|
||||||
private readonly Socket socket;
|
private Socket socket;
|
||||||
private OpenWireFormat wireformat = new OpenWireFormat();
|
private OpenWireFormat wireformat = new OpenWireFormat();
|
||||||
private readonly BinaryReader socketReader;
|
private BinaryReader socketReader;
|
||||||
private readonly BinaryWriter socketWriter;
|
private BinaryWriter socketWriter;
|
||||||
private readonly Thread readThread;
|
private Thread readThread;
|
||||||
private bool closed;
|
private bool closed;
|
||||||
private IDictionary requestMap = new Hashtable(); // TODO threadsafe
|
private IDictionary requestMap = new Hashtable(); // TODO threadsafe
|
||||||
private short nextCommandId;
|
private short nextCommandId;
|
||||||
|
private bool started;
|
||||||
|
|
||||||
public event CommandHandler Command;
|
public event CommandHandler Command;
|
||||||
public event ExceptionHandler Exception;
|
public event ExceptionHandler Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public SocketTransport(string host, int port)
|
public SocketTransport(string host, int port)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Opening socket to: " + host + " on port: " + port);
|
//Console.WriteLine("Opening socket to: " + host + " on port: " + port);
|
||||||
socket = Connect(host, port);
|
socket = Connect(host, port);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method Start
|
||||||
|
/// </summary>
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
if (!started)
|
||||||
|
{
|
||||||
|
started = true;
|
||||||
|
|
||||||
NetworkStream networkStream = new NetworkStream(socket);
|
NetworkStream networkStream = new NetworkStream(socket);
|
||||||
socketWriter = new BinaryWriter(networkStream);
|
socketWriter = new BinaryWriter(networkStream);
|
||||||
socketReader = new BinaryReader(networkStream);
|
socketReader = new BinaryReader(networkStream);
|
||||||
|
@ -49,6 +63,8 @@ namespace OpenWire.Client.Core
|
||||||
readThread = new Thread(new ThreadStart(ReadLoop));
|
readThread = new Thread(new ThreadStart(ReadLoop));
|
||||||
readThread.Start();
|
readThread.Start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Oneway(Command command)
|
public void Oneway(Command command)
|
||||||
{
|
{
|
||||||
|
@ -75,7 +91,6 @@ namespace OpenWire.Client.Core
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Closing the socket");
|
|
||||||
lock (transmissionLock)
|
lock (transmissionLock)
|
||||||
{
|
{
|
||||||
socket.Close();
|
socket.Close();
|
||||||
|
@ -87,23 +102,12 @@ namespace OpenWire.Client.Core
|
||||||
|
|
||||||
public void ReadLoop()
|
public void ReadLoop()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Starting to read commands from ActiveMQ");
|
|
||||||
while (!closed)
|
while (!closed)
|
||||||
{
|
{
|
||||||
Command command = null;
|
Command command = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
command = (Command) wireformat.Unmarshal(socketReader);
|
command = (Command) wireformat.Unmarshal(socketReader);
|
||||||
if (command != null)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Received command: " + command);
|
|
||||||
if (command is RemoveInfo)
|
|
||||||
{
|
|
||||||
RemoveInfo info = (RemoveInfo) command;
|
|
||||||
Console.WriteLine("Remove CommandId: " + info.CommandId);
|
|
||||||
Console.WriteLine("Remove ObjectID: " + info.ObjectId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (EndOfStreamException e)
|
catch (EndOfStreamException e)
|
||||||
{
|
{
|
||||||
|
@ -115,11 +119,15 @@ namespace OpenWire.Client.Core
|
||||||
// stream closed
|
// stream closed
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
// error, assume closing
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (command is Response)
|
if (command is Response)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Received response!: " + command);
|
|
||||||
Response response = (Response) command;
|
Response response = (Response) command;
|
||||||
FutureResponse future = (FutureResponse) requestMap[response.CommandId];
|
FutureResponse future = (FutureResponse) requestMap[response.CorrelationId];
|
||||||
if (future != null)
|
if (future != null)
|
||||||
{
|
{
|
||||||
if (response is ExceptionResponse)
|
if (response is ExceptionResponse)
|
||||||
|
@ -142,7 +150,7 @@ namespace OpenWire.Client.Core
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("Unknown response ID: " + response.CommandId);
|
Console.WriteLine("ERROR: Unknown response ID: " + response.CommandId + " for response: " + response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -153,7 +161,7 @@ namespace OpenWire.Client.Core
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine("No handler available to process command: " + command);
|
Console.WriteLine("ERROR: No handler available to process command: " + command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,7 +174,7 @@ namespace OpenWire.Client.Core
|
||||||
{
|
{
|
||||||
lock (transmissionLock)
|
lock (transmissionLock)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Sending command: " + command + " with ID: " + command.CommandId + " response: " + command.ResponseRequired);
|
//Console.WriteLine("Sending command: " + command + " with ID: " + command.CommandId + " response: " + command.ResponseRequired);
|
||||||
|
|
||||||
wireformat.Marshal(command, socketWriter);
|
wireformat.Marshal(command, socketWriter);
|
||||||
socketWriter.Flush();
|
socketWriter.Flush();
|
||||||
|
@ -202,3 +210,4 @@ namespace OpenWire.Client.Core
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
namespace OpenWire.Client
|
||||||
|
{
|
||||||
|
public interface IStartable
|
||||||
|
{
|
||||||
|
void Start();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using OpenWire.Client.Commands;
|
using OpenWire.Client.Commands;
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ namespace OpenWire.Client
|
||||||
private Session session;
|
private Session session;
|
||||||
private ConsumerInfo info;
|
private ConsumerInfo info;
|
||||||
private bool closed;
|
private bool closed;
|
||||||
|
private Dispatcher dispatcher = new Dispatcher();
|
||||||
|
|
||||||
public event MessageHandler Listener;
|
public event MessageHandler Listener;
|
||||||
|
|
||||||
|
@ -28,22 +30,25 @@ namespace OpenWire.Client
|
||||||
/// <param name="message">An ActiveMQMessage</param>
|
/// <param name="message">An ActiveMQMessage</param>
|
||||||
public void Dispatch(ActiveMQMessage message)
|
public void Dispatch(ActiveMQMessage message)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Dispatching message to consumer: " + message);
|
dispatcher.Enqueue(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMessage Receive()
|
public IMessage Receive()
|
||||||
{
|
{
|
||||||
CheckClosed();
|
CheckClosed();
|
||||||
Thread.Sleep(60000);
|
return dispatcher.Dequeue();
|
||||||
// TODO
|
}
|
||||||
return null;
|
|
||||||
|
public IMessage Receive(long timeout)
|
||||||
|
{
|
||||||
|
CheckClosed();
|
||||||
|
return dispatcher.Dequeue(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMessage ReceiveNoWait()
|
public IMessage ReceiveNoWait()
|
||||||
{
|
{
|
||||||
CheckClosed();
|
CheckClosed();
|
||||||
// TODO
|
return dispatcher.DequeueNoWait();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
@ -38,9 +38,6 @@ namespace OpenWire.Client
|
||||||
activeMessage.ProducerId = info.ProducerId;
|
activeMessage.ProducerId = info.ProducerId;
|
||||||
activeMessage.Destination = (ActiveMQDestination) destination;
|
activeMessage.Destination = (ActiveMQDestination) destination;
|
||||||
|
|
||||||
Console.WriteLine("About to send message with MessageId: " + activeMessage.MessageId);
|
|
||||||
Console.WriteLine("About to send message with ProducerId: " + activeMessage.ProducerId);
|
|
||||||
Console.WriteLine("About to send message with Destination: " + activeMessage.Destination);
|
|
||||||
session.DoSend(destination, message);
|
session.DoSend(destination, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,12 +43,12 @@ namespace OpenWire.Client
|
||||||
{
|
{
|
||||||
if (acknowledgementMode == AcknowledgementMode.ClientAcknowledge)
|
if (acknowledgementMode == AcknowledgementMode.ClientAcknowledge)
|
||||||
{
|
{
|
||||||
MessageAck ack = new MessageAck();
|
MessageAck ack = CreateMessageAck(message);
|
||||||
// TODO complete packet
|
|
||||||
connection.SyncRequest(ack);
|
connection.SyncRequest(ack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IMessageConsumer CreateConsumer(IDestination destination)
|
public IMessageConsumer CreateConsumer(IDestination destination)
|
||||||
{
|
{
|
||||||
return CreateConsumer(destination, null);
|
return CreateConsumer(destination, null);
|
||||||
|
@ -57,11 +57,23 @@ namespace OpenWire.Client
|
||||||
public IMessageConsumer CreateConsumer(IDestination destination, string selector)
|
public IMessageConsumer CreateConsumer(IDestination destination, string selector)
|
||||||
{
|
{
|
||||||
ConsumerInfo command = CreateConsumerInfo(destination, selector);
|
ConsumerInfo command = CreateConsumerInfo(destination, selector);
|
||||||
connection.SyncRequest(command);
|
ConsumerId consumerId = command.ConsumerId;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
MessageConsumer consumer = new MessageConsumer(this, command);
|
MessageConsumer consumer = new MessageConsumer(this, command);
|
||||||
connection.AddConsumer(command.ConsumerId, consumer);
|
// lets register the consumer first in case we start dispatching messages immediately
|
||||||
|
connection.AddConsumer(consumerId, consumer);
|
||||||
|
|
||||||
|
connection.SyncRequest(command);
|
||||||
return consumer;
|
return consumer;
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
connection.RemoveConsumer(consumerId);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IQueue GetQueue(string name)
|
public IQueue GetQueue(string name)
|
||||||
{
|
{
|
||||||
|
@ -105,26 +117,21 @@ namespace OpenWire.Client
|
||||||
|
|
||||||
public void DisposeOf(DataStructure objectId)
|
public void DisposeOf(DataStructure objectId)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Disposing of session: " + objectId + " with datatype: " + objectId.GetDataStructureType());
|
// TODO dispose of all the session first?
|
||||||
/*
|
|
||||||
RemoveInfo command = new RemoveInfo();
|
RemoveInfo command = new RemoveInfo();
|
||||||
command.ObjectId = objectId;
|
command.ObjectId = objectId;
|
||||||
connection.SyncRequest(command);
|
connection.SyncRequest(command);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisposeOf(ConsumerId objectId)
|
public void DisposeOf(ConsumerId objectId)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Disposing of consumer: " + objectId);
|
|
||||||
connection.RemoveConsumer(objectId);
|
connection.RemoveConsumer(objectId);
|
||||||
/*
|
|
||||||
RemoveInfo command = new RemoveInfo();
|
RemoveInfo command = new RemoveInfo();
|
||||||
command.ObjectId = objectId;
|
command.ObjectId = objectId;
|
||||||
connection.SyncRequest(command);
|
connection.SyncRequest(command);
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ConsumerInfo CreateConsumerInfo(IDestination destination, string selector)
|
protected virtual ConsumerInfo CreateConsumerInfo(IDestination destination, string selector)
|
||||||
{
|
{
|
||||||
ConsumerInfo answer = new ConsumerInfo();
|
ConsumerInfo answer = new ConsumerInfo();
|
||||||
ConsumerId id = new ConsumerId();
|
ConsumerId id = new ConsumerId();
|
||||||
|
@ -143,7 +150,7 @@ namespace OpenWire.Client
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ProducerInfo CreateProducerInfo(IDestination destination)
|
protected virtual ProducerInfo CreateProducerInfo(IDestination destination)
|
||||||
{
|
{
|
||||||
ProducerInfo answer = new ProducerInfo();
|
ProducerInfo answer = new ProducerInfo();
|
||||||
ProducerId id = new ProducerId();
|
ProducerId id = new ProducerId();
|
||||||
|
@ -158,6 +165,13 @@ namespace OpenWire.Client
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual MessageAck CreateMessageAck(Message message)
|
||||||
|
{
|
||||||
|
MessageAck ack = new MessageAck();
|
||||||
|
// TODO complete packet
|
||||||
|
return ack;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Configures the message command
|
/// Configures the message command
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -8,25 +8,9 @@ using OpenWire.Client.Core;
|
||||||
|
|
||||||
namespace OpenWire.Client
|
namespace OpenWire.Client
|
||||||
{
|
{
|
||||||
|
|
||||||
[ TestFixture ]
|
[ TestFixture ]
|
||||||
public class ClientTest : TestSupport
|
public class ClientTest : TestSupport
|
||||||
{
|
{
|
||||||
|
|
||||||
[ Test ]
|
|
||||||
public void CreateOpenWireFormat()
|
|
||||||
{
|
|
||||||
OpenWireFormat format = new OpenWireFormat();
|
|
||||||
Assert.IsTrue(format != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
[ Test ]
|
|
||||||
public void CreateConnectionFactory()
|
|
||||||
{
|
|
||||||
IConnectionFactory factory = new ConnectionFactory("localhost", 61616);
|
|
||||||
Assert.IsTrue(factory != null, "created valid factory: " + factory);
|
|
||||||
}
|
|
||||||
|
|
||||||
[ Test ]
|
[ Test ]
|
||||||
public void SendAndSyncReceive()
|
public void SendAndSyncReceive()
|
||||||
{
|
{
|
||||||
|
@ -34,47 +18,32 @@ namespace OpenWire.Client
|
||||||
|
|
||||||
Assert.IsTrue(factory != null, "no factory created");
|
Assert.IsTrue(factory != null, "no factory created");
|
||||||
|
|
||||||
Console.WriteLine("Worked!");
|
|
||||||
|
|
||||||
using (IConnection connection = factory.CreateConnection())
|
using (IConnection connection = factory.CreateConnection())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Assert.IsTrue(connection != null, "no connection created");
|
Assert.IsTrue(connection != null, "no connection created");
|
||||||
Console.WriteLine("Created a connection!");
|
Console.WriteLine("Connected to ActiveMQ!");
|
||||||
|
|
||||||
ISession session = connection.CreateSession();
|
ISession session = connection.CreateSession();
|
||||||
Console.WriteLine("Created a session: " + session);
|
|
||||||
|
|
||||||
IDestination destination = session.GetQueue("FOO.BAR");
|
IDestination destination = session.GetQueue("FOO.BAR");
|
||||||
Assert.IsTrue(destination != null, "No queue available!");
|
Assert.IsTrue(destination != null, "No queue available!");
|
||||||
Console.WriteLine("Using destination: " + destination);
|
|
||||||
|
|
||||||
IMessageConsumer consumer = session.CreateConsumer(destination);
|
IMessageConsumer consumer = session.CreateConsumer(destination);
|
||||||
Console.WriteLine("Created consumer!: " + consumer);
|
|
||||||
|
|
||||||
IMessageProducer producer = session.CreateProducer(destination);
|
IMessageProducer producer = session.CreateProducer(destination);
|
||||||
Console.WriteLine("Created producer!: " + producer);
|
|
||||||
|
|
||||||
string expected = "Hello World!";
|
string expected = "Hello World!";
|
||||||
ITextMessage request = session.CreateTextMessage(expected);
|
ITextMessage request = session.CreateTextMessage(expected);
|
||||||
Console.WriteLine("### About to send message: " + request);
|
|
||||||
|
|
||||||
producer.Send(request);
|
producer.Send(request);
|
||||||
Console.WriteLine("### Sent message!");
|
|
||||||
|
|
||||||
ITextMessage message = (ITextMessage) consumer.Receive();
|
ITextMessage message = (ITextMessage) consumer.Receive();
|
||||||
if (message == null)
|
|
||||||
{
|
|
||||||
Console.WriteLine("### No message!!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("### Received message: " + message + " of type: " + message.GetType());
|
|
||||||
String actual = message.Text;
|
|
||||||
|
|
||||||
Console.WriteLine("### Message text is: " + actual);
|
Assert.IsNotNull(message, "No message returned!");
|
||||||
}
|
|
||||||
|
Assert.AreEqual(expected, message.Text, "the message text");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
using NUnit.Framework;
|
||||||
|
using OpenWire.Client.Commands;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace OpenWire.Client
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class CommandTest
|
||||||
|
{
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCommand()
|
||||||
|
{
|
||||||
|
ConsumerId value1 = new ConsumerId();
|
||||||
|
value1.ConnectionId = "abc";
|
||||||
|
value1.SessionId = 123;
|
||||||
|
value1.Value = 456;
|
||||||
|
|
||||||
|
ConsumerId value2 = new ConsumerId();
|
||||||
|
value2.ConnectionId = "abc";
|
||||||
|
value2.SessionId = 123;
|
||||||
|
value2.Value = 456;
|
||||||
|
|
||||||
|
ConsumerId value3 = new ConsumerId();
|
||||||
|
value3.ConnectionId = "abc";
|
||||||
|
value3.SessionId = 123;
|
||||||
|
value3.Value = 457;
|
||||||
|
|
||||||
|
Assert.AreEqual(value1, value2, "value1 and value2 should be equal");
|
||||||
|
Assert.AreEqual(value1.GetHashCode(), value2.GetHashCode(), "value1 and value2 hash codes should be equal");
|
||||||
|
|
||||||
|
Assert.IsTrue(!value1.Equals(value3), "value1 and value3 should not be equal");
|
||||||
|
Assert.IsTrue(!value3.Equals(value2), "value3 and value2 should not be equal");
|
||||||
|
|
||||||
|
// now lets test an IDictionary
|
||||||
|
IDictionary dictionary = new Hashtable();
|
||||||
|
dictionary[value1] = value3;
|
||||||
|
|
||||||
|
// now lets lookup with a copy
|
||||||
|
object actual = dictionary[value2];
|
||||||
|
|
||||||
|
Assert.AreEqual(value3, actual, "Should have found item in Map using value2 as a key");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ using System.IO;
|
||||||
|
|
||||||
using OpenWire.Client;
|
using OpenWire.Client;
|
||||||
using OpenWire.Client.Core;
|
using OpenWire.Client.Core;
|
||||||
|
using OpenWire.Client.Commands;
|
||||||
|
|
||||||
namespace openwire_dotnet
|
namespace openwire_dotnet
|
||||||
{
|
{
|
||||||
|
@ -32,10 +33,14 @@ namespace openwire_dotnet
|
||||||
|
|
||||||
IMessageProducer producer = session.CreateProducer(destination);
|
IMessageProducer producer = session.CreateProducer(destination);
|
||||||
string expected = "Hello World!";
|
string expected = "Hello World!";
|
||||||
|
|
||||||
|
|
||||||
ITextMessage request = session.CreateTextMessage(expected);
|
ITextMessage request = session.CreateTextMessage(expected);
|
||||||
|
|
||||||
producer.Send(request);
|
producer.Send(request);
|
||||||
|
|
||||||
ITextMessage message = (ITextMessage) consumer.Receive();
|
Console.WriteLine("### About to receive message...");
|
||||||
|
ActiveMQTextMessage message = (ActiveMQTextMessage) consumer.Receive();
|
||||||
if (message == null)
|
if (message == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("### No message!!");
|
Console.WriteLine("### No message!!");
|
||||||
|
|
Loading…
Reference in New Issue