Multiple ports for a single application in jboss fuse - java

Relatively new to jboss fuse. We have a requirement of running a single application on multiple ports. Is it practically possible? specify a range of port in config file.
I tried like cfg.port: 9000, 9001
but doesnt work

The best approach is to have the application's Camel routes that use those ports define them in their routes. The built-in Jetty listener is generally for shared web service endpoints using CXF and the management web console.

Related

Hosting multiple netty servers for grpc inside a tomcat server, application redeploy issue

I am developing a microservice application and deploy them in single tomcat server. So I am not using spring boot. I am using just spring.
Let's say we have applications call master-data and common-service When I deploy them in tomcat I can access them via port 8080.
But I wanted them to transfer to grpc communication endpoints. Then I had to install grpc libries and netty for each modules. Now I can access their grpc endpoint in ports 6565 and 7575.
I used spring bean #PostConstruct annotation and separately run the grpc servers in separate ports (6565 and 7575). Now It works fine.
But when I add new changes to master-data and redeploy it in tomcat without shuting down the tomcat, It will gives me java.net.BindException: Address already in use
and when I run ps -ef | grep netty in terminal I could see there are processes still tuning on.
It seems like grpc server is not properly shut down because of tomcat is not shutting down.
Can anybody give me a proper solution ?
gRPC Java servers need to be shutdown by invoking their shutdown() method. I don't have much (any) knowledge about integrating gRPC Java with Tomcat/Spring, but there's no built-in integration on the gRPC side so you will need to ensure the gRPC servers are receiving a programmatic shutdown() signal somehow.
The grpc-java-contrib repository contains additional utilities for working with gRPC Java, including with Spring. In particular, it sounds like GrpcServerHost might be helpful for managing a server's lifecycle in a Spring environment.

Wildfly remote EJB calls through outbound connection through loadbalancer

We have some Wildfly servers running in standalone mode.
Every single instance provides a bunch of stateless services that can be accessed through ejb remote calls (http-remoting) from some webapplications.
The outbound connection of the webapplication points to a http loadbalancer using round robin, no stickiness. This balancers checks the availability of the service applications before connecting.
This work so far, failover also.
The problem:
The number of standalone servers could vary. Once an outbound connection is established from one of the webapps it will never be closed. So always the same standalone server is reached until it would die.
The purpose that under heavy load we just start another VM running a standalone server that would also be used by the loadbalancer does not work, because no new connection is established from the webapps.
Question:
Is this a scenario that could work, and if, is it possible to configure the webapps to start a new connection after some time, requests counts, or whatever?
I tried no keep alives for tcp or http header in undertow and request idle time, but no success so far.
Kind regards
Marcus
There is no easy way to dynamically load balance ejb remote calls due to their binary nature. The JBoss EJB client enables specifications of multiple remote connections, that are invoked in round-robin fashion, but the list is still hardcoded in your client config.
Example jboss client config jboss-ejb-client.properties:
endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=node1,node2
remote.connection.node1.host=192.168.1.105
remote.connection.node1.port = 4447
remote.connection.node1.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.node1.username=appuser
remote.connection.node1.password=apppassword
remote.connection.node2.host=192.168.1.106
remote.connection.node2.port = 4447
remote.connection.node2.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.node2.username=appuser
remote.connection.node2.password=apppassword
I understand, that your web application is also java based. Is there any reason why not run both the EJB layer and Web on the same server within a single .ear deployment? That way you could use local access, or even inject #EJB beans directly into your web controllers without the need to serialize all calls into binary form for remote EJB with the benefit of much simpler configuration and better performance.
If your application is actually a separate deployment then the preferred way is to expose your backend functionality via REST API(JAX-RS). This way it would be accessible via HTTP, that you could simply access from your web app and you can load balance it just like you did with your web UI(you can choose to keep your API http context private - visible only locally for the services on the same network, or make it public e.g. for mobile apps) .
Hope that helps
You should be using the standalone-ha.xml or standalone-full-ha.xml profile. While you might not need the ha part to manage the state of stateful beans across your cluster, you need it for the ejbclient to discover the other nodes in your cluster automatically
In effect, the load balancing is done by the ejbclient, not a separate dedicated load balancer

tomcat port URL restriction

I am trying to configure tomcat so that my application will be accessible via two different ports, say 8080 and 8980, but certain URLs will be accessible via only 8980.
The reason is that the web tier uses 8080 and I don't want certain URLs to be exposed to the outside world. I also don't want to configure web servers to restrict this, because of the coupling it creates between the app and the web tier.
I understand that I can configure two connectors and then programmatically block calls to the URLs based on the port, but:
I would rather not hard-code the port, as it may be changed in
the future in the server.xml
I want this same behaviour in various
applications in the organization, and don't want all developers to
need to implement this separately.
Is there a configuration where I can, perhaps, exclude certain URL patterns from a connector that is defined in server.xml?
Thanks in advance!
In tomcat, you can define multiple services with different connector ports and engine settings, but an application will only be served by one engine, so you'd have to deploy your application multiple times.
For use cases like yours, tomcat is too limited, but this functionality is usually deferred to a Reverse proxy, e.g. apache or nginx.
You could for example let your tomcat serve on port 8980, and configure an apache to reverse proxy all /app calls on port 8080, except the internals:
Listen 8080
<VirtualHost *:8080>
ProxyPass /app/internal !
ProxyPass /app http://localhost:8980/app
</VirtualHost>
See http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass

Bind IP address per ejb exposed as web service - jboss

How can I run ejbs exposed as a web services on the same jboss (version 4.2.3) using different IPs.
For example:
I have two web service locations (two different ejb components) and one server with two network interfaces:
http://192.168.0.1/test/TestService1
http://192.168.0.1/test/TestService2
and I want to have this:
http://192.168.0.1/test/TestService1
http://192.168.0.2/test/TestService2
Thanks
If JBoss is anything similar to websphere in it's architecture, I think you'll have two create to separate server instances and bind each to a specific IP. Then you'll deploy the EJB:s to the respective instance bound to the desired IP.

What do I need to realize notification using JMS?

I just need notification system. javax.jms.* - good solution I think, but I can't understand what do I need to use JMS?
I don't want to use any app. servers like GlassFish or Tomcat, I just would like to use standard jdk and myserver(very light) and myclient(very light too) and some MessageSystem to exchanging bitween myserver and myclient. As I understand to use JMS I need JMS Provider. For example: ActiveMQ. But I don't uderstand ActiveMQ needs any server?(GlassFish probably), and what kind of *.jar do I need from Java EE ?
JMS provider or more correctly a Message Broker can be a stand-alone application. Most of J2EE app servers include a broker inside them but yes we also have many very good stand alone JMS brokers, ActiveMQ is good, then there is OpenJMS and many others. And as they are stand alone they don't need another app server to run them. And they usually come with every needed jar as well :) SO you'll not need to copy any jar from other app-server to say ActiveMQ or OpenJMS.
ActiveMQ runs as a standalone server; it requires the Java VM like any Java application but nothing else beyond that.
Other stand alone JMS brokers (open source) which can be run standalone or even embedded in your Java application are Open Message Queue (OpenMQ) which is also included in GlassFish, and the new JBoss HornetQ message broker which will be the JMS implementation in JBoss application server.

Categories

Resources