I am curious why ConnectionMultiplexer.Connect(options) attempts to connect 2 clients to the RedisDB instead of 1? Each time I connect I see that 2 additional clients connect to my RedisDB.
Because redis requires separate connections for interactive commands versus pub/sub subscriptions. If you aren't using pub/sub, you could tell the options to disable the SUBSCRIBE command, in which case I believe the second connection is not established.
You can turn off second connection if you don't use redis pub/sub
var config = ConfigurationOptions.Parse(redisConnectionString);
config.CommandMap = CommandMap.Create(new HashSet<string> { "SUBSCRIBE" }, false);
connection = ConnectionMultiplexer.Connect(config);
Related
In one of our spring boot apps used in Springcloud dataflow streams, we are currently using HapiContext to construct a new HL7 client and establish a connection out of it to send HL7 messages to a TCP host and port.
#Autowired
HapiContext context;
Connection connection = context.newClient(host, Integer.parseInt(port), false);
// The initiator which will be used to transmit our message
Initiator initiator = connection.getInitiator();
Message response = initiator.sendAndReceive(adtMessage);
Currently we are not using SSL/TLS for this connection and call. but we now have a requirement such that the call should be changed to an SSL based one.
I have tried doing a lot of searches on the Internet, but I am not able to find any documentation on how to achieve this.
Is there anyway to get this done?
How are you creating the HapiContext?
The DefaultHapiContext seems to provide for creating a client with a tls parameter.
lookup for the ca.uhn.hl7v2.hoh.sockets.CustomCertificateTlsSocketFactory, this should have createClientSocket which will add the SSL context necessary
EdgeX uses Redis PubSub by default for its messaging bus (https://docs.edgexfoundry.org/2.3/microservices/application/Triggers/).
I have started the Redis server locally.
I have Core Data and/or Device Services running, which I believe is
also configured defaultly to use Redis Pub/Sub.
I have a Virtual Device Service that publishes data to the
edgex/events/# topic
(https://docs.edgexfoundry.org/2.3/microservices/device/virtual/Ch-VirtualDevice/).
Finally, I have configured my Application Service to subscribe to
the topic edgex/events/#, as shown in the example.
[Trigger.EdgexMessageBus]
Type = "redis" # message bus type (i.e "redis`, `mqtt` or `zero` for ZeroMQ)
[Trigger.EdgexMessageBus.SubscribeHost]
Host = "localhost"
Port = 6379
Protocol = "redis"
SubscribeTopics="edgex/events/#"
[Trigger.EdgexMessageBus.PublishHost]
Host = "localhost"
Port = 6379
Protocol = "redis"
PublishTopic="" # optional if publishing response back to the MessageBus
The Application Service is able to recieve all the messages sent to the topic.
However, when I go directly to the redis server (using redis-cli) and subscribe to SUBSCRIBE edgex/events/# or any other variant (edgex/events,edgex), nothing appears. Even checking PUBSUB CHANNELS shows that there are no active channels.
I am assuming that since EdgeX is using my localhost redis server (or any remote server, for that matter), that I'd be able to directly check with that redis server, subscribe to the topic that EdgeX is publishing to, and see the same messages.
Am I missing anything?
Thanks!
The EdgeX implementation is using PSUBSCRIBE with wildcards; the only command that will give you visibility is PUBSUB NUMPAT. You will need to identify the correct pattern for what you are trying to subscribe to AND have your subscriber running before anything is published as Redis PubSub is fire/forget.
Rather than going directly to Redis, I recommend using the EdgeX Application Services to subscribe and then either operate on the results directly or feed that to an external service.
I am using ServiceStack 5.0.2 with Redis Sentinel (3 + 3) and having issues in case of a failover: commands being issued during or after a failover fail with timeout.
I have come up with an idea to implement retry pattern via custom IRedisClient. But probably there is a better strategy to employ in this case.
Answer given in the post How does ServiceStack PooledRedisClientManager failover work? does not seem to be the right way to go.
Thank you,
Redis Clients wrap a TCP connection with a Redis Server, a Redis Client that was connected with the instance that failed over will fail, but any new Redis Clients retrieved from the pool after failover will be connected to the new failed over instance.
I have some files to be uploaded to an SFTP server, so I use JSch to accomplish this goal.
I have these options for implementation:
JSch opens one session and one channel
JSch opens one session and multiple channels
The above two solutions, which is more efficient?
Does one session correspond to a TCP connection, or does one channel correspond to a TCP connection?
If one session corresponds to a TCP connection, then multiple channels must share the same TCP connection, can it be more efficient?
One SSH session corresponds to one TCP connection. A channel is just a virtual "connection" within the one SSH/TCP connection.
As you have rightly assumed, it can hardly be more efficient to use multiple channels.
Option to use multiple channels is not for efficiency, but for flexibility (imo).
Actually using multiple channels can be less efficient.
It depends on how efficiently the SSH parties implement an SSH flow control (sliding window), comparing to efficiency of a TCP flow control (which will usually be super-optimized).
Some SFTP clients, when they know that only one channel will be opened, deliberately set client-side SSH window to a huge number, to leave the flow control to TCP (expecting it to be more efficient).
Also, PuTTY-based SFTP clients (like psftp or WinSCP) announce to the server that it will only ever use one channel (using a proprietary simple#putty.projects.tartarus.org message), so that the server can also opt to leave flow control to TCP too. Not that I know of any SSH server to actually take advantage of this.
I wish to run an experiment in which the publisher loses connection with the broker and then enqueues messages in its own queue and then when it regains connectivity it sends all its queued messages to the broker. How can I I do this since if I call close connection, I can no longer send(raises an exception). A trick that I can think of is to use a network of two brokers and simulate the above by breaking the connection between the two brokers. Is there an API call that I can use to do the above?
This is very much like facebook messenger or whatsapp acting as a publisher and enqueuing our to-send messages if we are offline and sending them once we are connected.
There is plenty of solutions you could use to break the connection in order to test, here is a non-comprehensive list :
Make a script that can set/unset a firewall rule on your environement blocking the connection port
If you are working with VMs, you can suspend/resume the one running Activemq, you can even automate it with tools like vagrant (vagrant suspend, then vagrant up)
Tweak the connection manualy accessing the activemq jmx
Develop an activemq plugin able to trash connections on demand (or maybe there is one ?)
Now in order to have the behavior you wish to obtain there is two options :
1) Make sure your connection is failover so it can be reestablished, and store your message on disk before sending them with your producer.
2)Produce to a local broker embbeded in your app, and connect this one to the remote broker.