/// <summary> /// 消息消费构造器 /// </summary> /// <param name="brokerUri">地址</param> /// <param name="username">用户名</param> /// <param name="psw">密码</param> /// <param name="clientId">客户端标识 兼做队列接收目的地</param> /// <param name="isClient">true 客户端;false 服务端</param> public OpenWireConsumer(string brokerUri, string username, string psw, string clientId,bool isClient) { NMSConnectionFactory _factory = new NMSConnectionFactory(brokerUri, clientId); _connection = _factory.CreateConnection(username, psw); _connection.Start(); _session = _connection.CreateSession(AcknowledgementMode.AutoAcknowledge); if (isClient) { _qReceiveDest = _session.GetDestination(clientId, DestinationType.TemporaryQueue); } else { _qReceiveDest = _session.GetQueue(clientId); } _messageConsumer = _session.CreateConsumer(_qReceiveDest); _messageConsumer.Listener += (message) => { if (Listener != null) { Listener(message); } }; }
public CallIndirect(LIRMethod parent, ISource targetMethod, IEnumerable<ISource> sources = null, IDestination returnValueDest = null) : base(parent, LIROpCode.CallIndirect) { this.TargetMethod = targetMethod; if (sources != null) Sources.AddRange(sources); this.ReturnValueDestination = returnValueDest; }
public Producer(ISession session, IDestination dest, int count, MsgPriority priority) { this.session = session; this.dest = dest; this.count = count; this.priority = priority; }
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; }
public Task Initialize(IDestination actor, long repeats) { this.actor = actor; this.repeats = repeats; return TaskDone.Done; }
public Convert(LIRMethod parent, ISource source, LIRType sourceType, IDestination dest, LIRType destType) : base(parent, LIROpCode.Convert) { Source = source; SourceType = sourceType; Destination = dest; DestinationType = destType; }
public String Receive(String queueName) { String message = ""; using (IConnection connection = factory.CreateConnection()) using (ISession session = connection.CreateSession()) { destination = SessionUtil.GetDestination(session, "queue://" + queueName); Console.WriteLine("Using destination: " + destination); using (IMessageConsumer consumer = session.CreateConsumer(destination)) { connection.Start(); ITextMessage textMessage = consumer.Receive() as ITextMessage; if (textMessage == null) { Console.WriteLine("No message received!"); } else { message = textMessage.Text; } } } return message; }
public Unary(LIRMethod parent, ISource src, IDestination dest, UnaryOperation op, LIRType argType) : base(parent, LIROpCode.Unary) { Source = src; Destination = dest; Operation = op; ArgumentType = argType; }
protected JmsPort(string destination) { _connection = null; _factory = null; _session = null; _destination = null; Configure(destination); }
/// <summary> /// Default constructor /// </summary> /// <param name="destination">Destionation to connect with OpenEngSB</param> protected JmsPort(string destination) { connection = null; factory = null; session = null; this.destination = null; Configure(destination); }
public Destination(IDestination destination) { if (destination == null) throw new ArgumentNullException("destination"); this.destination = destination; this.destinationType = DestinationType.Destination; }
public Math(LIRMethod parent, ISource srcA, ISource srcB, IDestination dest, MathOperation op, LIRType argType) : base(parent, LIROpCode.Math) { SourceA = srcA; SourceB = srcB; Destination = dest; Operation = op; ArgumentType = argType; }
public Compare(LIRMethod parent, ISource sourceA, ISource sourceB, IDestination destination, LIRType type, CompareCondition condition) : base(parent, LIROpCode.Compare) { this.SourceA = sourceA; this.SourceB = sourceB; this.Destination = destination; this.Type = type; this.Condition = condition; }
public NmsSystemEventsImpl(INmsOperations nmsOperations, IDestination cargoHandledDestination, IDestination cargoUpdateDestination) { this.nmsOperations = nmsOperations; this.cargoHandledDestination = cargoHandledDestination; this.cargoUpdateDestination = cargoUpdateDestination; }
public IMessageConsumer CreateConsumer(IDestination destination, string selector, bool noLocal) { if (selector != null) { throw new NotImplementedException("Selectors are not supported by MSQM"); } MessageQueue queue = MessageConverter.ToMsmqDestination(destination); return new MessageConsumer(this, acknowledgementMode, queue); }
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); }
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); }
private void PurgeQueue(IConnection conn, IDestination queue) { ISession session = conn.CreateSession(); IMessageConsumer consumer = session.CreateConsumer(queue); while(consumer.Receive(TimeSpan.FromMilliseconds(500)) != null) { } consumer.Close(); session.Close(); }
public PooledProducer(IMessageProducer producer, IDestination destination) { this.producer = producer; this.destination = destination; this.deliveryMode = producer.DeliveryMode; this.disableMessageID = producer.DisableMessageID; this.disableMessageTimestamp = producer.DisableMessageTimestamp; this.priority = producer.Priority; this.timeToLive = producer.TimeToLive; }
/// <summary> /// Default constructor /// </summary> /// <param name="destination">Destionation to connect with OpenEngSB</param> protected JmsPort(string destination, EExceptionHandling handling) { this.connection = null; this.factory = null; this.session = null; this.destination = null; this.string_destination=destination; this.handling=handling; this.nbrretry = 0; Configure(); }
public void removeTempDestination(IDestination destination) { for(int i = tempDestinations.Count - 1; i >= 0; i--) { DestinationInfo di = tempDestinations[i]; if(di.Destination.Equals(destination)) { tempDestinations.RemoveAt(i); } } }
public Master(IUserService service) { DownloadUsers = new DownloadUsers(service); Factory = new NMSConnectionFactory("tcp://localhost:61616"); Connection = Factory.CreateConnection(); Connection.Start(); Session = Connection.CreateSession(AcknowledgementMode.AutoAcknowledge); Destination = SessionUtil.GetDestination(Session, "Users"); Receiver = Session.CreateConsumer(Destination); }
private void Configure(string destination) { Destination dest = new Destination(destination); Uri connectionUri = new Uri(dest.Host); _factory = new NMSConnectionFactory(connectionUri); _connection = _factory.CreateConnection(); _session = _connection.CreateSession(); _connection.Start(); _destination = _session.GetDestination(dest.Queue); }
/// <summary> /// Configurate the Connection /// </summary> /// <param name="destination">Destionation</param> private void Configure(string destination) { Destination dest = new Destination(destination); Uri connectionUri = new Uri(dest.Host); factory = new Apache.NMS.ActiveMQ.ConnectionFactory(connectionUri); connection = factory.CreateConnection(); session = connection.CreateSession(); connection.Start(); this.destination = session.GetDestination(dest.Queue); }
public void Purge(ISession session, IDestination destination) { lock (destinations) { if (!destinations.Contains(destination)) { session.DeleteDestination(destination); destinations.Add(destination); } } }
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."); }
public void 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, transactional ? XMSC.DELIVERY_PERSISTENT : XMSC.DELIVERY_NOT_PERSISTENT); consumer = session.CreateConsumer(queue); connection.Start(); connected = true; }
public void Send(IDestination destination, IMessage message, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive) { if (destination == null) { destination = this.destination; } IMessageProducer producer = this.MessageProducer; lock(producer) { producer.Send(destination, message, deliveryMode, priority, timeToLive); } }
public void RequestDeferredMessages(IDestination browseDestination) { var session = SessionFactory.GetSession(); var amqSchedulerManagementDestination = session.GetTopic(ScheduledMessage.AMQ_SCHEDULER_MANAGEMENT_DESTINATION); using (var producer = session.CreateProducer(amqSchedulerManagementDestination)) { var request = session.CreateMessage(); request.Properties[ScheduledMessage.AMQ_SCHEDULER_ACTION] = ScheduledMessage.AMQ_SCHEDULER_ACTION_BROWSE; request.NMSReplyTo = browseDestination; producer.Send(request); } }
public void SendMessage(String message, String queueName) { using (IConnection connection = factory.CreateConnection()) using (ISession session = connection.CreateSession()) { destination = SessionUtil.GetDestination(session, "queue://" + queueName); Console.WriteLine("Using destination: " + destination); using (IMessageProducer producer = session.CreateProducer(destination)) { connection.Start(); ITextMessage request = session.CreateTextMessage(message); producer.Send(request); } } }
public void ImportAddress(IDestination address, string label, bool rescan) { SendCommand(RPCOperations.importaddress, address.ScriptPubKey.ToHex(), label, rescan); }
protected abstract IDestination DoTransformDestination(IDestination destination);
// importaddress public void ImportAddress(IDestination address) { SendCommand(RPCOperations.importaddress, address.ScriptPubKey.ToHex()); }
public virtual void Init(TBlockTemplate blockTemplate, string jobId, PoolConfig poolConfig, XPoolConfig clusterConfig, IMasterClock clock, IDestination poolAddressDestination, BitcoinNetworkType networkType, bool isPoS, double shareMultiplier, decimal blockrewardMultiplier, IHashAlgorithm coinbaseHasher, IHashAlgorithm headerHasher, IHashAlgorithm blockHasher) { Assertion.RequiresNonNull(blockTemplate, nameof(blockTemplate)); Assertion.RequiresNonNull(poolConfig, nameof(poolConfig)); Assertion.RequiresNonNull(clusterConfig, nameof(clusterConfig)); Assertion.RequiresNonNull(clock, nameof(clock)); Assertion.RequiresNonNull(poolAddressDestination, nameof(poolAddressDestination)); Assertion.RequiresNonNull(coinbaseHasher, nameof(coinbaseHasher)); Assertion.RequiresNonNull(headerHasher, nameof(headerHasher)); Assertion.RequiresNonNull(blockHasher, nameof(blockHasher)); Assertion.Requires <ArgumentException>(!string.IsNullOrEmpty(jobId), $"{nameof(jobId)} must not be empty"); this.poolConfig = poolConfig; this.clusterConfig = clusterConfig; this.clock = clock; this.poolAddressDestination = poolAddressDestination; this.networkType = networkType; BlockTemplate = blockTemplate; JobId = jobId; Difficulty = new Target(new NBitcoin.BouncyCastle.Math.BigInteger(BlockTemplate.Target, 16)).Difficulty; extraNoncePlaceHolderLength = BitcoinConstants.ExtranoncePlaceHolderLength; this.isPoS = isPoS; this.shareMultiplier = shareMultiplier; this.blockRewardMultiplier = blockrewardMultiplier; this.coinbaseHasher = coinbaseHasher; this.headerHasher = headerHasher; this.blockHasher = blockHasher; if (!string.IsNullOrEmpty(BlockTemplate.Target)) { blockTargetValue = new uint256(BlockTemplate.Target); } else { var tmp = new Target(BlockTemplate.Bits.HexToByteArray()); blockTargetValue = tmp.ToUInt256(); } previousBlockHashReversedHex = BlockTemplate.PreviousBlockhash .HexToByteArray() .ReverseByteOrder() .ToHexString(); BuildMerkleBranches(); BuildCoinbase(); jobParams = new object[] { JobId, previousBlockHashReversedHex, coinbaseInitialHex, coinbaseFinalHex, merkleBranchesHex, BlockTemplate.Version.ToStringHex8(), BlockTemplate.Bits, BlockTemplate.CurTime.ToStringHex8(), false }; }
public Transaction EmitMoney(Money money, IDestination destination, bool broadcast = true, bool coinbase = false) { return(EmitMoney(money, destination.ScriptPubKey, broadcast, coinbase)); }