本文整理汇总了C#中ISession.CreateProducer方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.CreateProducer方法的具体用法?C# ISession.CreateProducer怎么用?C# ISession.CreateProducer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISession
的用法示例。
在下文中一共展示了ISession.CreateProducer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Publisher
public Publisher(ISession session, string topicName)
{
this.session = session;
DestinationName = topicName;
topic = new ActiveMQTopic(DestinationName);
Producer = session.CreateProducer(topic);
}
示例2: TopicPublisher
public TopicPublisher(ISession session, string topicName)
{
_session = session;
DestinationName = topicName;
_topic = new Apache.NMS.ActiveMQ.Commands.ActiveMQTopic(DestinationName);
Producer = session.CreateProducer(_topic);
}
示例3: UpdateConnection
// Verbindung zum Messaging-Server aktualisieren
public void UpdateConnection()
{
try
{
// eventuell früher belegte Ressourcen freigeben
CleanupResources();
// Verbindung / Session / MessageProducer und -Consumer instanziieren
if (connectionFactory == null)
{
Console.WriteLine(brokerURL);
connectionFactory = new ConnectionFactory(brokerURL);
}
connection = connectionFactory.CreateConnection();
session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
messageProducer = session.CreateProducer(new ActiveMQTopic(topicName));
// Thread zum Empfang eingehender Nachrichten starten
connection.Start();
Console.WriteLine("Connection geändert, Broker-URL ist " + brokerURL);
}
catch (Exception e)
{
Console.WriteLine("*** EXCEPTION in updateConnection(): " + e.Message);
}
}
示例4: Queue
public Queue(MsgDeliveryMode mode = MsgDeliveryMode.NonPersistent)
{
Uri msgQueue = new Uri("activemq:tcp://localhost:61616");
_factory = new ConnectionFactory(msgQueue);
try
{
_connection = _factory.CreateConnection();
}
catch (NMSConnectionException ex)
{
Log.FatalException("Error connecting to MQ server", ex);
throw;
}
// TODO check _connection for null
_connection.RequestTimeout = TimeSpan.FromSeconds(60);
Session = _connection.CreateSession();
// TODO need to find out if queue exists.
// It creates a new queue if it doesn't exist.
_destination = Session.GetDestination("queue://TwitterSearchStream");
_consumer = Session.CreateConsumer(_destination);
_producer = Session.CreateProducer(_destination);
_producer.RequestTimeout = TimeSpan.FromSeconds(60);
_producer.DeliveryMode = mode;
_connection.Start();
_connection.ExceptionListener += _connection_ExceptionListener;
_connection.ConnectionInterruptedListener += _connection_ConnectionInterruptedListener;
}
示例5: QueuePublisher
public QueuePublisher(ISession session, string queueName)
{
this.session = session;
DestinationName = queueName;
queue = SessionUtil.GetQueue(session, DestinationName);
Producer = session.CreateProducer(queue);
}
示例6: TopicPublisher
public TopicPublisher(ISession session, string topicName)
{
this.session = session;
DestinationName = topicName;
topic = SessionUtil.GetTopic(session, DestinationName);
Producer = session.CreateProducer(topic);
}
示例7: MessageTransporter
public MessageTransporter()
{
_connectionFactory = new Apache.NMS.Stomp.ConnectionFactory("tcp://0.0.0.0:61613");
_connection = _connectionFactory.CreateConnection();
_session = _connection.CreateSession();
_destination = SessionUtil.GetDestination(_session, "queue://testingQueue");
_messageProducer = _session.CreateProducer(_destination);
_messageConsumer = _session.CreateConsumer(_destination);
}
示例8: Connect
private void Connect()
{
factory = XmsUtilities.CreateConnectionFactory(destination);
connection = factory.CreateConnection();
connection.ExceptionListener += OnError;
session = connection.CreateSession(transactional, AcknowledgeMode.AutoAcknowledge);
queue = session.CreateQueue(destination.Queue);
queue.SetIntProperty(XMSC.DELIVERY_MODE, XMSC.DELIVERY_PERSISTENT);
producer = session.CreateProducer(queue);
}
示例9: UnparsedQueueManager
public UnparsedQueueManager(SystemConfig config)
{
Uri connecturi = new Uri(config.ACTIVEMQ_URI);
IConnectionFactory factory = NMSConnectionFactory.CreateConnectionFactory(connecturi);
connection = factory.CreateConnection();
session = connection.CreateSession();
connection.Start();
IDestination destination = SessionUtil.GetDestination(session, config.UNPARSED_QUEUE);
producer = session.CreateProducer(destination);
}
示例10: ActiveProducer
public ActiveProducer(IConnection amqConnection, ISession amqSession, String amqQueueName, EasyNetQ.IBus rabbitBus)
{
_rabbitBus = rabbitBus;
ActiveMQQueue topic = new ActiveMQQueue(amqQueueName);
_amqProducer = amqSession.CreateProducer(topic);
countOfMessages = 0;
_timProducer = new Timer(2000);
_timProducer.Elapsed += _timProducer_Elapsed;
_timProducer.Enabled = true;
log.Info("Producer Connected to Queue '" + amqQueueName + "'");
}
示例11: Connect
public void Connect()
{
log.Debug("New physical producer created. About to connect.");
factory = XmsUtilities.CreateConnectionFactory(address);
connection = factory.CreateConnection();
connection.ExceptionListener += OnError;
session = connection.CreateSession(transactional, AcknowledgeMode.AutoAcknowledge);
queue = session.CreateQueue(address.Queue);
queue.SetIntProperty(XMSC.DELIVERY_MODE, XMSC.DELIVERY_PERSISTENT);
producer = session.CreateProducer(queue);
connected = true;
log.Debug("New physical producer successfully connected.");
}
示例12: ActiveMq
public ActiveMq(bool durable)
{
_connectionFactory = new ConnectionFactory("tcp://localhost:61616");
_connectionFactory.AsyncSend = true;
_connectionFactory.ProducerWindowSize = int.MaxValue;
_connection = _connectionFactory.CreateConnection();
_connection.ClientId = "13AC0CF8-65FE-4638-8B85-62210DD89BEE";
_connection.Start();
_session = _connection.CreateSession();
ActiveMQTopic topic = new ActiveMQTopic("topic");
_consumer = _session.CreateDurableConsumer(topic, "durable", "2 > 1", false);
_producer = _session.CreateProducer(topic);
_producer.DeliveryMode = durable ? MsgDeliveryMode.Persistent : MsgDeliveryMode.NonPersistent;
}
示例13: Stomp
public Stomp(bool durable)
{
_connectionFactory = new ConnectionFactory("tcp://localhost:61613");
_connection = _connectionFactory.CreateConnection();
_connection.ClientId = "13AC0CF8-65FE-4638-8B85-62210DD89BEE";
_connection.Start();
_session = _connection.CreateSession();
var topic = _session.GetQueue("exampleQueue");
_producer = _session.CreateProducer(topic);
_producer.DeliveryMode = durable ? MsgDeliveryMode.Persistent : MsgDeliveryMode.NonPersistent;
_consumer = _session.CreateConsumer(topic);
}
示例14: TestQueueRollbackConsumerListener
public void TestQueueRollbackConsumerListener()
{
connection.Start();
this.session = connection.CreateSession(AcknowledgementMode.Transactional);
ITemporaryQueue queue = session.CreateTemporaryQueue();
IMessageProducer producer = session.CreateProducer(queue);
IMessage message = session.CreateTextMessage("Test Message");
producer.Send(message);
session.Commit();
IMessageConsumer consumer = session.CreateConsumer(queue);
consumer.Listener += new MessageListener(OnMessageListener);
Thread.Sleep(500);
// first try.. should get 2 since there is no delay on the
// first redeliver..
Assert.AreEqual(2, counter);
Thread.Sleep(1000);
// 2nd redeliver (redelivery after 1 sec)
Assert.AreEqual(3, counter);
Thread.Sleep(2000);
// 3rd redeliver (redelivery after 2 seconds) - it should give up after
// that
Assert.AreEqual(4, counter);
// create new message
producer.Send(session.CreateTextMessage("Test Message Again"));
session.Commit();
Thread.Sleep(500);
// it should be committed, so no redelivery
Assert.AreEqual(5, counter);
Thread.Sleep(1500);
// no redelivery, counter should still be 5
Assert.AreEqual(5, counter);
session.Close();
}
示例15: Server
public Server()
{
InitializeComponent();
listBox1.DataSource = listener;
//服务端
String brokerUri = "stomp:tcp://" + host + ":" + port + "?transport.useLogging=true";
factory = new NMSConnectionFactory(brokerUri);
connection = factory.CreateConnection(user, password);
connection.Start();
session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
consumer = session.CreateConsumer(session.GetQueue(re_destination));
producer = session.CreateProducer();
listener.Add("Starting up Listener.");
listener.Add("Waiting for messages...");
t1 = new Thread(new ThreadStart(StartListener));
}