How can Jedis connect to a redis server using a socket connection? - redis

I'm having problems figuring out how to use the Jedis library to connect to a redis socket connection.
I know how to connect through a network port:
Jedis jedis = new Jedis("localhost");
//Jedis jedis = new Jedis(unix_socket_path="/tmp/redis.sock");
But the socket connection(second in the list) doesn't work. The commands looked simlair to redis-py(python client) but when I tried the same syntax it didn't work. I also looked through the jedis sourcecode on github but couldn't see anything. Any ideas?

I don't think Jedis support unix domain sockets.
The constructor with a single parameter only accepts a hostname (using default TCP port).
Java is portable. It is supposed to provide the same API on different platforms. Unix domain sockets are specific to Unix/Linux. So the Java standard API does not support unix domain sockets. There are separate Java packages for this, but AFAIK, Jedis do not use them.

Related

Failover and client timeout

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.

TLS/SSL connection to Redis when using spring-data-redis

What is the recommended way to make a TLS/SSL connection to Redis sentinel using spring-data-redis and Jedis?
I'm using spring-data-redis 1.8.3.RELEASE with Jedis 2.9.0.
I understand that Redis does not provide direct support for TLS/SSL and instead recommends a secure proxy like spiped or stunnel. So lets assume I have setup the appropriate secure tunnels.
I can see that JedisConnectionFactory has a setUseSsl(boolean useSsl) method, but the value only seems to be used in createRedisPool() and not createRedisSentinelPool(), which leads me to think it is currently not possible with Redis sentinel.
Additionally, even when using standalone Redis and setting useSsl to true, there doesn't appear to be a way to set the SSLSocketFactory or parameters, so it will likely end up relying on the JVM's SSL system properties which is problematic if those aren't the SSL properties you wanted to use to connection to the secure tunnel.
Just trying to confirm if my above assumptions are correct, and if not then looking for pointers in the right direction. Thanks.

How to open connection to redis from signalr hub

I am using a redis server as my backplane for my signalr application.
I fully understand how to write and read from the redis server - but what is the best practice for connecting to the redis server from my hub class?
For example adding a reference to the server as below using stackexchange.redis, but where and when to call this in my hub class? Obviously I want to persist this connection. I'm totally stuck on this right now.
Private redis As StackExchange.Redis.ConnectionMultiplexer = ConnectionMultiplexer.Connect("127.0.0.1:6379")

ActiveMQ embedded with MQTT and Default MQ enabled, Possible to publish to both in one call?

I am using ActiveMQ embedded in Glassfish with both the default 61616 communication port and a port with MQTT enabled.
Is there a way to publish to both of these MQs in one call if ActiveMQ is configured a certain way?
If not, is the only way to connect to the MQTT server from the J2EE server through a 3rd party MQTT client?
If so, is there a MQTT lib that can take advantage of J2EE container's connection pools?
All protocols in ActiveMQ will share the same topics and queues.
You can subscribe and publish as you wish from java/JMS and the data will be accessible on the same topic using MQTT.
Of course, there will be some issues if you use JMS-only features, such as ObjectMessage and whatnot, but that is pretty obvious. Stick to text messages on topics and you should be fine.

Legacy application to communicate with cloud foundry using RabbitMQ

I am new to cloud foundry and investigating possible ways for our legacy Java EE application to communicate asynchronously with an application running on cloud foundry.
We are doing a lot of asynchronous work already and are publishing events to Active MQ.
I know that cloud foundry has a possibility to bind with Rabbit MQ and my question is with the possibility for a cloud foundry running application to connect (listen) to an existing out of CF platform Rabbit MQ?
Any idea on other alternatives to achieve this?
Yes, that is possible. You can use a user provided service.
That allows you to inject the environment variables into your app, that are needed to connect to RabbitMQ (like host, port, vhost, username, password).
Once you create that service, you can bind it to your app. Inside your app code, you then can read the environment variables exactly the same way as you would do it, if you had used a RabbitMQ service provided by CloudFoundry.