Ejemplo n.º 1
0
        public void Start(int maximumConcurrencyLevel)
        {
            startSubscriptionThread = new Thread(() =>
            {
                foreach (var tuple in events.GetConsumingEnumerable())
                {
                    var messageReceiver = Builder.Build <IMessageReceiver>();
                    Address address     =
                        Address.Parse(String.Format("topic://{0}/EVENTS/#/{1}/#", WebSphereMqAddress.GetQueueName(tuple.Item2),
                                                    tuple.Item1.FullName));
                    var consumerSatellite = new EventConsumerSatellite(messageReceiver, address,
                                                                       tuple.Item1.FullName);

                    messageReceiver.Init(address, settings, tryProcessMessage, endProcessMessage, consumerSatellite.CreateConsumer);

                    satellites.Add(consumerSatellite);
                    Logger.InfoFormat("Starting receiver for [{0}] subscription.", address);

                    consumerSatellite.Start(maximumConcurrencyLevel);
                }
            })
            {
                IsBackground = true
            };

            startSubscriptionThread.SetApartmentState(ApartmentState.MTA);
            startSubscriptionThread.Name = "Start WebSphereMq Subscription Listeners";
            startSubscriptionThread.Start();
        }
        public void Init(Address address, TransactionSettings settings, Func <TransportMessage, bool> tryProcessMessage,
                         Action <TransportMessage, Exception> endProcessMessage)
        {
            isTheMainTransport = address == Address.Local;

            endpointAddress = new WebSphereMqAddress(address);

            if (address == Address.Local)
            {
                subscriptionsManager.Init(settings, tryProcessMessage, endProcessMessage);
            }

            messageReceiver.Init(address, settings, tryProcessMessage, endProcessMessage, session => session.CreateConsumer(session.CreateQueue(endpointAddress.QueueName)));
        }
Ejemplo n.º 3
0
        public void CreateQueueIfNecessary(Address address, string account)
        {
            var queueName = WebSphereMqAddress.GetQueueName(address);

            var properties = new Hashtable
            {
                { MQC.HOST_NAME_PROPERTY, Settings.Hostname },
                { MQC.PORT_PROPERTY, Settings.Port },
                { MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES },
                { MQC.CHANNEL_PROPERTY, Settings.Channel },
                { MQC.SSL_CIPHER_SPEC_PROPERTY, Settings.SslCipherSpec },
                { MQC.SSL_CERT_STORE_PROPERTY, Settings.SslKeyRepository },
                { MQC.SSL_PEER_NAME_PROPERTY, Settings.SslPeerName }
            };

            using (var queueManager = new MQQueueManager(Settings.QueueManager, properties))
            {
                var agent   = new PCFMessageAgent(queueManager);
                var request = new PCFMessage(CMQCFC.MQCMD_CREATE_Q);
                request.AddParameter(MQC.MQCA_Q_NAME, queueName);
                request.AddParameter(MQC.MQIA_Q_TYPE, MQC.MQQT_LOCAL);
                request.AddParameter(MQC.MQIA_MAX_Q_DEPTH, Settings.MaxQueueDepth);

                try
                {
                    agent.Send(request);
                }
                catch (PCFException ex)
                {
                    if (ex.ReasonCode == PCFException.MQRCCF_CFST_STRING_LENGTH_ERR)
                    {
                        throw new ArgumentException(String.Format("Queue name too long:{0}", queueName));
                    }

                    if (ex.ReasonCode != PCFException.MQRCCF_OBJECT_ALREADY_EXISTS)
                    {
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public IMessageConsumer CreateConsumer(ISession session)
 {
     return(session.CreateDurableSubscriber(session.CreateTopic(WebSphereMqAddress.GetQueueName(address)), eventType));
 }
        public bool Publish(TransportMessage message, IEnumerable <Type> eventTypes)
        {
            var eventTypeTopics = String.Join("/", eventTypes);

            messageSender.Send(message, Address.Parse(String.Format("topic://{0}/EVENTS/{1}", WebSphereMqAddress.GetQueueName(Address.Local), eventTypeTopics)));

            return(true);
        }