diff options
| author | Arnaud Simon <arnaudsimon@apache.org> | 2008-09-26 13:13:40 +0000 |
|---|---|---|
| committer | Arnaud Simon <arnaudsimon@apache.org> | 2008-09-26 13:13:40 +0000 |
| commit | f79dde7183d5cc2a3a358dc7314b18102aaae652 (patch) | |
| tree | 5a57b2968aeadbcd2732002eec96856ca9658d62 /dotnet | |
| parent | 8b4503d429cea7029101e09f57beb967bcc29b47 (diff) | |
| download | qpid-python-f79dde7183d5cc2a3a358dc7314b18102aaae652.tar.gz | |
qpid-1277: simplified message interface
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@699304 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'dotnet')
| -rw-r--r-- | dotnet/client-010/client/client/ClientInterface.cs | 1 | ||||
| -rw-r--r-- | dotnet/client-010/client/client/ClientSession.cs | 24 | ||||
| -rw-r--r-- | dotnet/client-010/client/client/ClientSessionDelegate.cs | 6 | ||||
| -rw-r--r-- | dotnet/client-010/client/client/IMessage.cs | 46 | ||||
| -rw-r--r-- | dotnet/client-010/client/client/Message.cs | 121 | ||||
| -rw-r--r-- | dotnet/client-010/client/client/MessageListenerInterface.cs | 8 | ||||
| -rw-r--r-- | dotnet/client-010/client/transport/Session.cs | 2 |
7 files changed, 193 insertions, 15 deletions
diff --git a/dotnet/client-010/client/client/ClientInterface.cs b/dotnet/client-010/client/client/ClientInterface.cs index ed95933799..85be5886c6 100644 --- a/dotnet/client-010/client/client/ClientInterface.cs +++ b/dotnet/client-010/client/client/ClientInterface.cs @@ -18,7 +18,6 @@ */
using System;
-using client.client;
namespace org.apache.qpid.client
{
diff --git a/dotnet/client-010/client/client/ClientSession.cs b/dotnet/client-010/client/client/ClientSession.cs index 10f1109031..2f107dc0b2 100644 --- a/dotnet/client-010/client/client/ClientSession.cs +++ b/dotnet/client-010/client/client/ClientSession.cs @@ -2,8 +2,10 @@ using System;
using System.Collections.Generic;
-using client.client;
+using System.IO;
+using System.Text;
using org.apache.qpid.transport;
+using org.apache.qpid.transport.util;
namespace org.apache.qpid.client
{
@@ -24,20 +26,34 @@ namespace org.apache.qpid.client public static short MESSAGE_ACQUIRE_ANY_AVAILABLE_MESSAGE = 0;
public static short MESSAGE_ACQUIRE_MESSAGES_IF_ALL_ARE_AVAILABLE = 1;
- private Dictionary<String, MessageListener> _listeners = new Dictionary<String, MessageListener>();
+ private Dictionary<String, IMessageListener> _listeners = new Dictionary<String, IMessageListener>();
public ClientSession(byte[] name) : base(name)
{
}
- public void attachMessageListener(MessageListener listener, string Destination)
+ public void attachMessageListener(IMessageListener listener, string Destination)
{
_listeners.Add(Destination, listener);
}
- public Dictionary<String, MessageListener> MessageListeners
+ public Dictionary<String, IMessageListener> MessageListeners
{
get { return _listeners; }
}
+
+ public void messageTransfer(String destination, string routingkey, IMessage message)
+ {
+ byte[] body = new byte[message.Body.Position];
+ message.Body.Seek(0, SeekOrigin.Begin);
+ message.Body.Read(body, 0, body.Length);
+ message.MessageProperties.setMessageId(UUID.randomUUID());
+ message.DeliveryProperties.setRoutingKey(routingkey);
+ messageTransfer(destination,
+ MessageAcceptMode.NONE,
+ MessageAcquireMode.PRE_ACQUIRED,
+ message.Header,
+ body);
+ }
}
}
\ No newline at end of file diff --git a/dotnet/client-010/client/client/ClientSessionDelegate.cs b/dotnet/client-010/client/client/ClientSessionDelegate.cs index 087f2d2006..1b40e2ba45 100644 --- a/dotnet/client-010/client/client/ClientSessionDelegate.cs +++ b/dotnet/client-010/client/client/ClientSessionDelegate.cs @@ -16,8 +16,6 @@ * specific language governing permissions and limitations
* under the License.
*/
-using System;
-using client.client;
using org.apache.qpid.transport;
using org.apache.qpid.transport.util;
@@ -34,8 +32,8 @@ namespace org.apache.qpid.client {
if (((ClientSession) session).MessageListeners.ContainsKey(xfr.getDestination()))
{
- MessageListener listener = ((ClientSession) session).MessageListeners[xfr.getDestination()];
- listener.messageTransfer(xfr);
+ IMessageListener listener = ((ClientSession)session).MessageListeners[xfr.getDestination()];
+ listener.messageTransfer( new Message(xfr));
}
else
{
diff --git a/dotnet/client-010/client/client/IMessage.cs b/dotnet/client-010/client/client/IMessage.cs new file mode 100644 index 0000000000..b669867ebb --- /dev/null +++ b/dotnet/client-010/client/client/IMessage.cs @@ -0,0 +1,46 @@ +/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.IO;
+using org.apache.qpid.transport;
+
+namespace org.apache.qpid.client
+{
+ public interface IMessage
+ {
+ int Id { get; }
+
+ Header Header { get; set; }
+
+ MessageProperties MessageProperties { get; set; }
+
+ DeliveryProperties DeliveryProperties { get; set; }
+
+ Dictionary<String, Object> ApplicationHeaders { get; set; }
+
+ void appendData(byte[] bytes);
+
+ MemoryStream Body { get; }
+
+ void clearData();
+ }
+}
diff --git a/dotnet/client-010/client/client/Message.cs b/dotnet/client-010/client/client/Message.cs new file mode 100644 index 0000000000..934ce60e68 --- /dev/null +++ b/dotnet/client-010/client/client/Message.cs @@ -0,0 +1,121 @@ +/*
+*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*
+*/
+using System.Collections.Generic;
+using System.IO;
+using org.apache.qpid.transport;
+
+namespace org.apache.qpid.client
+{
+ public class Message : IMessage
+ {
+ private readonly MessageTransfer _message;
+
+ public Message(MessageTransfer m)
+ {
+ _message = m;
+ }
+
+ public Message()
+ {
+ _message = new MessageTransfer();
+ _message.Header = new Header( new MessageProperties(), new DeliveryProperties());
+ ((MessageProperties) _message.Header.Structs[0]).setApplicationHeaders(new Dictionary<string, object>());
+ }
+
+ public MessageProperties MessageProperties
+ {
+ get
+ {
+ if (_message.Header != null)
+ return (MessageProperties) Header.Structs[0];
+ return null;
+ }
+ set
+ {
+ if (_message.Header != null)
+ {
+ Header.Structs[0] = value;
+ }
+ }
+ }
+
+ public DeliveryProperties DeliveryProperties
+ {
+ get
+ {
+ if (Header != null)
+ return (DeliveryProperties) Header.Structs[1];
+ return null;
+ }
+ set
+ {
+ if (Header != null)
+ {
+ Header.Structs[1] = value;
+ }
+ }
+ }
+
+ public Dictionary<string, object> ApplicationHeaders
+ {
+ get
+ {
+ if (Header != null)
+ return ((MessageProperties) Header.Structs[0]).getApplicationHeaders();
+ return null;
+ }
+ set
+ {
+ if (Header != null)
+ {
+ ((MessageProperties) Header.Structs[0]).setApplicationHeaders(value);
+ }
+ }
+ }
+
+ public void appendData(byte[] bytes)
+ {
+ Body.Write(bytes, 0, bytes.Length);
+ }
+
+ public void clearData()
+ {
+ Body.Seek(0, SeekOrigin.Begin);
+ }
+
+ public Header Header
+ {
+ get{ return _message.Header;}
+ set{ _message.Header = value;}
+ }
+
+ public MemoryStream Body
+ {
+ get { return _message.Body; }
+ set { _message.Body = value; }
+ }
+
+ public int Id
+ {
+ get { return _message.Id; }
+ }
+ }
+}
diff --git a/dotnet/client-010/client/client/MessageListenerInterface.cs b/dotnet/client-010/client/client/MessageListenerInterface.cs index ac56ff8c99..978248e04c 100644 --- a/dotnet/client-010/client/client/MessageListenerInterface.cs +++ b/dotnet/client-010/client/client/MessageListenerInterface.cs @@ -16,16 +16,16 @@ * specific language governing permissions and limitations
* under the License.
*/
-using org.apache.qpid.transport;
-namespace client.client
+
+namespace org.apache.qpid.client
{
- public interface MessageListener
+ public interface IMessageListener
{
/// <summary>
/// Inform the listener of the message transfer
/// </summary>
/// <param name="xfr">The message transfer object</param>
- void messageTransfer(MessageTransfer xfr);
+ void messageTransfer(IMessage xfr);
}
}
diff --git a/dotnet/client-010/client/transport/Session.cs b/dotnet/client-010/client/transport/Session.cs index f97fb44568..69afb68046 100644 --- a/dotnet/client-010/client/transport/Session.cs +++ b/dotnet/client-010/client/transport/Session.cs @@ -22,8 +22,6 @@ using System; using System.Collections.Generic;
using System.IO;
using System.Threading;
-using common.org.apache.qpid.transport.util;
-using org.apache.qpid.transport;
using org.apache.qpid.transport.util;
using Frame = org.apache.qpid.transport.network.Frame;
using Logger = org.apache.qpid.transport.util.Logger;
|
