12 Ekim 2021 Salı

Wildfly

Giriş
Eski ismi JBoss. Açıklaması şöyle
WildFly (formerly known as JBoss Application Server) is an open-source JavaEE application server developed and first released by JBoss in February, 2008.
Açıklaması şöyle. Red Hat tarafından sağlanıyor. İçinde gömülü bir ActiveMQ bulunur
Wildfly is a complete implementation of Jakarta EE backed by Red Hat, that provides much more functionality than the specification. It has, for example, an embedded ActiveMQ message queue, that can be used by your modules for asynchronous communication. It also provides a security vault, that can be used to store passwords and sensitive strings. It can be run in domain mode, to load balance and replicate data throughout the cluster. Jakarta EE is already a container platform, so your modules or applications can run in isolation and be deployed independently of each other. It also provides you with a web console to administer and monitor your application server. And I just scratched the surface. So, can Wildfly replace a cloud platform for enterprise software? Yes.
Cluster Mimarisi
Şeklen şöyle

Açıklaması şöyle
As you can see, the backbone of WildFly clustering is the JGroups library, which provides a reliable multicast system used by cluster members to find each other and communicate. Next comes Infinispan, which is a data grid platform that is used by the application server to keep in sync the application data in the cluster by means of a replicated and transactional JSR-107 compatible cache. Infinispan is used both as a Cache for standard session mechanisms (HTTP Sessions and SFSB session data) and as advanced caching mechanism for JPA and Hibernate objects (aka second level cache).

To get the clustering feature, WildFly provides two profiles:

- ha: clustering of EJB and Web applications
- full-ha: : clustering of EJB, Web applications and JMS applications
Açıklaması şöyle
The simplest way to start a cluster in standalone mode is therefore to use a configuration that is cluster-aware, for example:

$ ./standalone.sh -c standalone-ha.xml
Now from another console another instance of WildFly, using a port offset to avoid clashing with the ports opened by the first server:

$ ./standalone.sh -c standalone-ha.xml -Djboss.socket.binding.port-offset=100
Intellij Ultimate Edition kullanıyorsak, JBoss/Wildfly ile profile seçme açıklaması burada 
 
Gradle
Bir sürü örnekte container'a mahsus maven örnekleri var. Örneğin "wildfly-jakartaee8-with-tools"
Ama bunlar yerine jakarta.jakartaee-api dependency'lerini kullanmak lazım

Örnek - wildfly 12
Java 8 ile çalışan basit bir REST uygulaması için şöyle yaparız
dependencies {
    compileOnly 'javax:javaee-api:8.0'
}
Örnek
Şöyle yaparız
<dependency>
  <groupId>javax</groupId>
  <artifactId>javaee-api</artifactId>
  <version>7.0</version>
  <scope>provided</scope>
</dependency>
Çalıştırmak
Örnek
Şöyle yaparız
WILDFLY_HOME/bin/standalone.sh
Örnek
Şöyle yaparız
For Linux:   JBOSS_HOME/bin/standalone.sh -c standalone-full.xml
For Windows: JBOSS_HOME\bin\standalone.bat -c standalone-full.xml
MicroProfile Configuration Subsystem
Not : Bu subsystem hep sorun çıkartıyor, o yüzden ben de standalone-ha.xml dosyasından kaldırıyorum

Açıklaması şöyle
The MicroProfile config has been implemented in WildFly with the following subsystem:

<subsystem xmlns="urn:wildfly:microprofile-config-smallrye:1.0"/>
This subsystem in turns requires the following extension:

<extension module="org.wildfly.extension.microprofile.config-smallrye"/>
When this subsystem is activated, the configuration will be injected into the org.eclipse.microprofile.config.Config object. This configuration object contains the information collected from several configuration locations, called ConfigSources and stored in org.eclipse.microprofile.config.spi.ConfigSource. By default there are 3 default ConfigSources:

1. System.getProperties()
2. System.getenv()
3. All META-INF/microprofile-config.properties files on the ClassPath
Daha sonra bun nesneye erişmek için şöyle yaparız
import org.eclipse.microprofile.config.inject.ConfigProperty;

@WebServlet(name = "config", urlPatterns = { "/config" })
public class ConfigServlet extends HttpServlet {
  
  @Inject
  @ConfigProperty(name = "text1")
  String prop1;
  
  @Inject
  @ConfigProperty(name = "text2", defaultValue="Hello World")
  String prop2;
  ...

}
Elytron Subsystem
Elytron Subsystem yazısına taşıdım

JBOSS_MODULEPATH Ortam Değişkeni
Normalde sunucu $JBOSS_HOME/modules/ dizinini okur. Eğer bu dizine bir şey daha ilave etmek istersek şöyle yaparız
export JBOSS_MODULEPATH=$JBOSS_HOME/modules:/foo/bar/modules
Kullanıcı Eklemek
"Management User" ve "Application User" diye iki farklı kullanıcı tipi vardır. "Management User" deployment yapabilir. Çıktısı şöyle.
Örnek
Şöyle yaparız. Kullanıcı ManagementRealm'e eklenir
WILDFLY_HOME/bin/add-user.sh username password
Açıklaması şöyle
This user is added to the ManagementRealm and is authorized to perform management operations using the web-based Management Console or command-line based Management CLI. The other choice, b, adds a user to the ApplicationRealm, and provides no particular permissions. That realm is provided for use with applications.
--silent seçeneği
Açıklaması şöyle
You can suppress the normal output of the add-user script by passing the --silent parameter. This applies only if the minimum parameters username and password have been specified. Error messages will still be shown.
Örnek
Şöyle yaparız.
add-user.sh admin Admin#123 --silent
Kubernetes vs Widfly
Şeklen şöyle




Şeklen şöyle









Hiç yorum yok:

Yorum Gönder