Databases and Business Analysts--airhacks.fm podcast

Subscribe to airhacks.fm podcast via: spotify| iTunes| RSS

The #124 airhacks.fm episode with Ben Brumm (@databasestar) about:
databases, business analysts, database tools, database development and the object-relational impedance mismatch
is available for

Quarkus, Kafka, java.lang.IllegalStateException: SRMSG00028 and the Solution

The following exception:


java.lang.IllegalStateException: SRMSG00028: The subscription to ... has been cancelled
at io.smallrye.reactive.messaging.extension.AbstractEmitter.verify(AbstractEmitter.java:165)
at io.smallrye.reactive.messaging.extension.AbstractEmitter.emit(AbstractEmitter.java:144)
at io.smallrye.reactive.messaging.extension.EmitterImpl.send(EmitterImpl.java:29)
at airhacks.kafka.jaxrs.boundary.MessagesResource.send(MessagesResource.java:34)
at airhacks.kafka.jaxrs.boundary.MessagesResource_Subclass.send$$superaccessor1(MessagesResource_Subclass.zig:209)
at airhacks.kafka.jaxrs.boundary.MessagesResource_Subclass$$function$$3.apply(MessagesResource_Subclass$$function$$3.zig:33)    

is caused by an injected Emitter into a RequestScoped managed bean:


import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.*;

import org.eclipse.microprofile.reactive.messaging.Channel;
import org.eclipse.microprofile.reactive.messaging.Emitter;

@RequestScoped
@Path("messages")
@Consumes(MediaType.TEXT_PLAIN)
public class MessagesResource {

    @Inject
    @Channel("messages")
    Emitter<String> messageEmitter;
    
    @POST
    public void send(String message) {
        this.messageEmitter.send(message);
    }

    @PreDestroy
    public void closeStream(){
        this.messageEmitter.complete();
    }
}

Changing the scope to ApplicationScoped solves the problem:


@ApplicationScoped
@Path("messages")
@Consumes(MediaType.TEXT_PLAIN)
public class MessagesResource{
    //...
}

Example was tested with: quarkus.io and configured SmallRye Apache Kafka connector (mp.messaging.outgoing.messages.connector=smallrye-kafka).

An offline JavaDoc search PWA

devdocs.io is a useful documentation / API search Progressive Web App (PWA) with offline search capabilities.

devdocs.io is not only usable as a search utility for Web Components or webstandards APIs, also Java 11 javadoc is available for offline search:

Converting a byte[] to Stream

The following snippet converts a byte[] array to a Stream using ByteBuffer:


import java.nio.ByteBuffer;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.junit.jupiter.api.Test;

public class ByteArrayTest {
    
    @Test
    public void byteArrayToStream(){
        byte bytes[] = new byte[]{0xC,0xA,0xF,0xE,0xB,0xA,0xB,0xE};
        var buffer = ByteBuffer.wrap(bytes);
        var message = Stream.generate(() -> buffer.get()).
                        limit(buffer.capacity()).
                        map(b -> Integer.toHexString(b)).
                        collect(Collectors.joining());
        System.out.println(message);
    }    

Output: cafebabe

Plasma is the new "Hello,World"--airhacks.fm podcast

Subscribe to airhacks.fm podcast via: spotify| iTunes| RSS

The #123 airhacks.fm episode with Bert Jan Schrijver (@bjschrijver) about:
AI, Java EE, Java, serverless, Quarkus, and a bit of plasma
is available for

Avoiding Port Collisions by Launching Multiple Quarkus Instances in DEV Mode

Quarkus started in development (quarkus:dev) mode with a JAX-RS endpoint exposed, opens two ports: (http) 8080 and (debug) 5005 per default.

You will have to assign distinct ports for every new launched instance. The http port is configurable in the application.properties: quarkus.http.port=8282 or environment entries (not suitable for our purpose), the debug port can be changed (-Ddebug=6000) or deactivated from the command line only: mvn compile -Ddebug=false quarkus:dev

Early 2021 Java, Web, Architecture Events, Conferences And Workshops

  1. WeAreDevelopers conference: 2021: Familiar APIs on Kickass Runtimes #slideless [online event]
    conference session 20 Jan 2021
  2. airhacks.tv: #83rd airhacks.tv Questions and Answers [online event]
    live questions and answers show 8 Feb 2021
  3. JavaLand conference: Timesaving Metrics - In The Clouds #slideless [online event]
    conference session 16 Mar 2021
  4. airhacks.live: Monoliths, Microservices, Serverless, Event-Driven,(...) Architectural Styles [online event]
    live, interactive, virtual workshop 16 Mar 2021
  5. airhacks.live: Building Event-Driven Applications with Streams, Logs and Messages [online event]
    live, interactive, virtual workshop 23 Mar 2021
  6. airhacks.live: Best Practices, Hacks and Frontend Patterns with Vanilla Web Components, redux and lit-html [online event]
    live, interactive, virtual workshop 15 Apr 2021
  7. airhacks.live: Building Mobile Apps with Vanilla Web Components, redux and lit-html [online event]
    live, interactive, virtual workshop 6 May 2021

microprofile.training: Java 14 to Java 15 Update and MP REST Client CXF to RESTEasy Migration

Update from Java 14 with --enable-preview to Java 15, fixing Apache CXFs:

java.lang.IllegalAccessError: class org.apache.cxf.microprofile.client.MicroProfileClientProviderFactory$$Lambda$345/0x0000000800c309b0 tried to access protected method 'int org.apache.cxf.jaxrs.provider.ProviderFactory.compareCustomStatus(org.apache.cxf.jaxrs.model.ProviderInfo, org.apache.cxf.jaxrs.model.ProviderInfo)' (org.apache.cxf.microprofile.client.MicroProfileClientProviderFactory$$Lambda$345/0x0000000800c309b0 and org.apache.cxf.jaxrs.provider.ProviderFactory are in unnamed module of loader 'app'

by switching from cxf-rt-rs-mp-client to resteasy-client-microprofile.

A free bonus video from the microprofile.training video course:

Also checkout the corresponding repository: github.com/adambien/microprofile.training.

Java CLI Apps, Builds and jbang--airhacks.fm podcast

Subscribe to airhacks.fm podcast via: spotify| iTunes| RSS

The #122 airhacks.fm episode with Max Rydahl Andersen (@maxandersen) about:
creating Java Command Line Applications with and without jbang, new ways to launch and build Java applications with minimal requirements, how jbang happened, combining quarkus and jbang, and building serverless applications with quarkus and jbang
is available for

Future.works: The Feel of Next Generation Java Cloud Native Runtimes

Building a Java backend service with familiar APIs on a next generation runtime:

Online Workshops
...the last 150 posts
...the last 10 comments
License