<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Franco Torriani on Medium]]></title>
        <description><![CDATA[Stories by Franco Torriani on Medium]]></description>
        <link>https://medium.com/@franco.torriani?source=rss-be84e07af666------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*evk8qjABhDnNN2Mnfjaotg.jpeg</url>
            <title>Stories by Franco Torriani on Medium</title>
            <link>https://medium.com/@franco.torriani?source=rss-be84e07af666------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 01:54:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@franco.torriani/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Jev, Java and Quarkus: I Fired My Ticket Triage and Hired a Probability]]></title>
            <link>https://medium.com/@franco.torriani/jev-java-and-quarkus-i-fired-my-ticket-triage-and-hired-a-probability-f028660ad6e5?source=rss-be84e07af666------2</link>
            <guid isPermaLink="false">https://medium.com/p/f028660ad6e5</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[jevs]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[quarkus]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Franco Torriani]]></dc:creator>
            <pubDate>Sun, 11 Oct 2026 23:02:13 GMT</pubDate>
            <atom:updated>2026-10-11T23:02:13.555Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OkgUaCiiAix9n3zW" /><figcaption>Photo by <a href="https://unsplash.com/@edge2edgemedia?utm_source=medium&amp;utm_medium=referral">Edge2Edge Media</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The whole world is talking about <a href="https://typesafe.ai/">Jev</a>, and who am I to ignore this stuff?</p><p>So I took the most honest route: pick a boring, real problem and see whether the hype survives contact with it.</p><p>The problem is support tickets. Every support desk has that one colleague whose whole job is to read them and announce “this one’s for DevOps”, and I tried to replace them with a model that never sighs, never asks for a raise and, unlike most LLMs, never answers with a three-paragraph essay: it answers with types and probabilities.</p><p>The result is a small hexagonal Quarkus service built on Jev that decides how urgent a ticket is, how bad it is and who should handle it, and that, when it is not sure, has the decency to ask a human. The code is available on my GitHub: <a href="https://github.com/darkwings/jevving">darkwings/jevving</a>.</p><h3>Why a ticket dispatcher</h3><p>Every support desk starts the same way: someone reads a new request and decides where it goes.</p><ul><li>Is the customer in a hurry, or just fond of capital letters?</li><li>Is production down, or is it a typo in the footer?</li><li>Is this a job for DevOps, for the developers or for the account manager, who is, as usual, in a meeting?</li></ul><p>A generative LLM can do this for sure, provided you enjoy parsing endless prose. You ask for JSON, you get a courteous paragraph that contains some JSON, and the model’s own idea of “fairly confident” is yours to interpret.</p><p>For routing I wanted the opposite: a fixed set of options, a typed answer, and a probability I can put a threshold on.</p><p>That is exactly what Jev offers, so a ticket dispatcher looked like a small, honest use case to try it on. Small enough to finish, honest enough to show where it hurts.</p><p>Needless to say, as we’ll see, this is a perfect fit with the strong typing of Java.</p><h3>Jev in two minutes</h3><p><a href="https://docs.typesafe.ai/introduction">Jev</a> is TypeSafe’s “System One” model: it does not write text, it makes fast, structured decisions. You send a <strong>state</strong> (the text to evaluate) and a set of named, typed <strong>questions</strong>; you get back typed answers with probability distributions.</p><p>There are three question types:</p><ul><li>noul: you send a yes/no statement, you get back noul, from 0 (no) to 1 (yes).</li><li>choice: you send a map of option id → description, you get back the chosen option, probabilities and confidence.</li><li>score: you send an ordered list of 2–10 levels, you get back a probability-weighted score, probabilities per level and confidence.</li></ul><p>All questions in a request are evaluated in parallel against the same state, so asking three questions costs about as much as asking one. This is an example of the request the PoC sends for every ticket:</p><pre>POST https://api.typesafe.ai/v1/systemone<br>Authorization: Bearer &lt;API_KEY&gt;<br>{<br>  &quot;state&quot;: &quot;Our production site is down, the load balancer returns 503 to every customer!&quot;,<br>  &quot;model&quot;: &quot;jev-latest&quot;,<br>  &quot;questions&quot;: {<br>    &quot;urgent&quot;: { <br>      &quot;type&quot;: &quot;noul&quot;, <br>      &quot;instructions&quot;: &quot;Does the customer&#39;s message convey a need for immediate help?&quot; <br>    },<br>    &quot;team&quot;: {<br>      &quot;type&quot;: &quot;choice&quot;,<br>      &quot;instructions&quot;: &quot;Which team is best placed to resolve this request?&quot;,<br>      &quot;criteria&quot;: {<br>        &quot;devops&quot;: &quot;AWS Dev-ops support for infrastructure problems&quot;,<br>        &quot;developers&quot;: &quot;Support on software bugs&quot;,<br>        &quot;business&quot;: &quot;Business problems, big customer relationship&quot;,<br>        &quot;sales&quot;: &quot;Marketing support&quot;,<br>        &quot;unclear&quot;: &quot;The request is too vague or ambiguous to tell which team should handle it&quot;<br>      }<br>    },<br>    &quot;severity&quot;: {<br>      &quot;type&quot;: &quot;score&quot;,<br>      &quot;instructions&quot;: &quot;How serious is the problem the customer reports?&quot;,<br>      &quot;criteria&quot;: [&quot;MINOR&quot;, &quot;MAJOR&quot;, &quot;BLOCKER&quot;]<br>    }<br>  }<br>}</pre><p>And the shape of what comes back (values are illustrative…<em> and no, any DevOps was harmed by my PoC</em>):</p><pre>{<br>  &quot;model&quot;: &quot;jev-1.13.0&quot;,<br>  &quot;answers&quot;: {<br>    &quot;urgent&quot;: { <br>      &quot;type&quot;: &quot;noul&quot;, <br>      &quot;noul&quot;: 0.97 <br>    },<br>    &quot;team&quot;: { <br>      &quot;type&quot;: &quot;choice&quot;, <br>      &quot;choice&quot;: &quot;devops&quot;, <br>      &quot;confidence&quot;: 0.9,<br>      &quot;probabilities&quot;: { <br>        &quot;devops&quot;: 0.9, <br>        &quot;developers&quot;: 0.05, <br>        &quot;business&quot;: 0.03, <br>        &quot;sales&quot;: 0.02 <br>      } <br>    },<br>    &quot;severity&quot;: { <br>      &quot;type&quot;: &quot;score&quot;,<br>      &quot;score&quot;: 1.8, <br>      &quot;confidence&quot;: 0.8,<br>      &quot;legend&quot;: { <br>        &quot;0&quot;: &quot;MINOR&quot;, <br>        &quot;1&quot;: &quot;MAJOR&quot;, <br>        &quot;2&quot;: &quot;BLOCKER&quot; <br>      },<br>      &quot;probabilities&quot;: { <br>        &quot;0&quot;: 0.02, <br>        &quot;1&quot;: 0.16, <br>        &quot;2&quot;: 0.82<br>      } <br>    }<br>  },<br>  &quot;usage&quot;: { <br>    &quot;input_tokens&quot;: 120, <br>    &quot;output_tokens&quot;: 3 <br>  }<br>}</pre><p>No parsing, no prompt engineering on the output format, just numbers and labels my code can branch on.</p><h3>Step 1: a Quarkus project and its configuration</h3><p>The stack is Quarkus 3.40 on Java 25, built with Gradle. I started from a plain Quarkus REST project and added the Jev settings to application.properties:</p><pre>jev.api-key=${TYPESAFE_API_KEY}<br>jev.base-url=https://api.typesafe.ai<br>jev.model=jev-latest</pre><pre>quarkus.rest-client.jev.url=${jev.base-url}</pre><p>The API key never lives in the file: it comes from the TYPESAFE_API_KEY environment variable. To read the jev.* keys as a typed object, SmallRye Config&#39;s @ConfigMapping is all it takes. Kebab-case keys map to camelCase methods on their own:</p><pre>@ConfigMapping(prefix = &quot;jev&quot;)<br>public interface JevConfiguration {<br>    String apiKey();    <br>    String baseUrl();<br>    String model();<br>}</pre><p>Inject it anywhere with @Inject JevConfiguration config;. If the environment variable is missing, the app refuses to start, which is what you want for a credential.</p><h3>Step 2: a typed client for Jev</h3><p>The client is a declarative Quarkus REST Client: an interface, an endpoint and a filter that adds the bearer token.</p><pre>@RegisterRestClient(configKey = &quot;jev&quot;)<br>@RegisterProvider(JevAuthFilter.class)<br>@Path(&quot;/v1/systemone&quot;)<br>@Consumes(MediaType.APPLICATION_JSON)<br>@Produces(MediaType.APPLICATION_JSON)<br>public interface JevRestClient {<br><br>    @POST<br>    Uni&lt;JevResponse&gt; evaluate(JevRequest request);<br>}</pre><pre>@ApplicationScoped<br>public class JevAuthFilter implements ClientRequestFilter {<br>    @Inject<br>    JevConfiguration config;<br><br>    @Override<br>    public void filter(ClientRequestContext context) {<br>        context.getHeaders().putSingle(HttpHeaders.AUTHORIZATION, &quot;Bearer &quot; + config.apiKey());<br>    }<br>}</pre><p>The interesting part is the payload. Jev’s answers are polymorphic: each one carries a type field that says which of the three shapes it has. A <strong>sealed interface</strong> of records maps that one to one, and Jackson picks the right record from the typeproperty:</p><pre>@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = &quot;type&quot;)<br>@JsonSubTypes({<br>        @JsonSubTypes.Type(value = JevAnswer.Noul.class, name = &quot;noul&quot;),<br>        @JsonSubTypes.Type(value = JevAnswer.Choice.class, name = &quot;choice&quot;),<br>        @JsonSubTypes.Type(value = JevAnswer.Score.class, name = &quot;score&quot;)<br>})<br>public sealed interface JevAnswer {<br><br>    record Noul(double noul) implements JevAnswer {<br>    }<br><br>    record Choice(String choice, double confidence, Map&lt;String, Double&gt; probabilities) implements JevAnswer {<br>    }<br><br>    record Score(double score, double confidence, Map&lt;String, String&gt; legend,<br>                 Map&lt;String, Double&gt; probabilities) implements JevAnswer {<br>    }<br>}</pre><p>Questions get the same treatment (JevQuestion.Noul, Choice, Score). Because the interface is sealed, a switch over an answer is exhaustive: if Jev ever adds a fourth type and I add the record, the compiler points at every place that has to handle it.</p><p>The flip side is deserialization: an unknown type would make Jackson fail the whole response. I chose to be tolerant and turned that into a null entry with an ObjectMapperCustomizer that disables DeserializationFeature.FAIL_ON_INVALID_SUBTYPE; the code that reads the answers then decides what a missing answer means.</p><p>The client is tested against <strong>WireMock</strong>, started by a QuarkusTestResourceLifecycleManager on a random port that also overrides jev.base-url and jev.api-key. The tests check both directions: the JSON we send and the records we get back.</p><pre>wiremock.verify(postRequestedFor(urlEqualTo(&quot;/v1/systemone&quot;))<br>        .withHeader(&quot;Authorization&quot;, equalTo(&quot;Bearer test-key&quot;))<br>        .withRequestBody(equalToJson(expectedRequestJson)));</pre><h3>Step 3: going hexagonal</h3><p>With a working client, the temptation is to call Jev straight from a REST resource and be done. I wanted the opposite: a domain that talks about <strong>tickets, teams, urgency and severity</strong>, and does not know Jev exists.</p><p>Jev becomes one possible implementation of a port.</p><p>The code is split into four packages:</p><ul><li>domain: entities (Ticket, SupportTeam), value objects, domain services, exceptions and <strong>ports</strong> (repositories and the assessor).</li><li>application: the use cases that orchestrate the ports.</li><li>infrastructure: the adapters, i.e. the Jev client and the in-memory repositories.</li><li>presentation: the REST API, its DTOs and mappers.</li></ul><p>The domain asks its own questions. Like Jev’s types, they are a sealed interface, one class per question in the language of the domain:</p><pre>public sealed interface Question {<br><br>    String questionId();<br><br>    String instructions();<br><br>    final class Urgency implements Question { /* &quot;Does the customer&#39;s message convey a need for immediate help?&quot; */ }<br><br>    final class Team implements Question {<br>        // built from the available support teams: team id → capability<br>        public Map&lt;String, String&gt; criteria() { ... }<br>    }<br><br>    final class SeverityScore implements Question {<br>        /** Ordered from least to most severe, so a higher score means a more severe issue. */<br>        public List&lt;String&gt; options() {<br>            return List.of(Severity.MINOR.name(), Severity.MAJOR.name(), Severity.BLOCKER.name());<br>        }<br>    }<br>}</pre><p>Answers mirror them, in domain terms: severity comes back as a Map&lt;Severity, Double&gt;, not as level indexes.</p><pre>public sealed interface Answer {<br><br>    record Urgency(double probability) implements Answer { }<br><br>    record Team(String chosenTeamId, double confidence, Map&lt;String, Double&gt; probabilities) implements Answer { }<br><br>    record SeverityScore(double score, double confidence, Map&lt;Severity, Double&gt; probabilities) implements Answer {<br>        public Severity mostLikely() { ... }<br>    }<br>}</pre><p>The port that ties them together is one method:</p><pre>public interface RequestAssessor {<br>    Uni&lt;Answers&gt; assess(String request, Questions questions);<br>}</pre><p>Questions and Answers are records with one field per question, so nobody looks answers up by string key outside the adapter.</p><p>One rule kept the layers honest: <strong>domain objects are never serialized</strong>. JSON lives only in the adapters&#39; DTOs and in the Jev client. That also let me use Lombok&#39;s fluent accessors (ticket.id() instead of ticket.getId()) in the domain without fighting Jackson.</p><h3>The architecture at a glance</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*yG3p85iMyek0LX8h6seytg.png" /></figure><p>A request enters through the presentation layer, a use case in the application layer orchestrates the work, and the domain holds the rules and the ports. Infrastructure plugs into those ports: swapping Jev for another assessor, or the in-memory maps for a database, touches nothing inside the domain.</p><h3>Step 4: the Jev adapter</h3><p>JevAssessor implements the port. It translates the domain questions into Jev questions, sends them in <strong>one</strong> request, and translates the answers back:</p><pre>@ApplicationScoped<br>public class JevAssessor implements RequestAssessor {<br><br>    // constructor injection of JevRestClient and JevConfiguration omitted<br>    @Override<br>    public Uni&lt;Answers&gt; assess(String request, Questions questions) {<br>        Map&lt;String, JevQuestion&gt; jevQuestions = new LinkedHashMap&lt;&gt;();<br>        jevQuestions.put(questions.urgency().questionId(), toJev(questions.urgency()));<br>        jevQuestions.put(questions.team().questionId(), toJev(questions.team()));<br>        jevQuestions.put(questions.severityScore().questionId(), toJev(questions.severityScore()));<br>        return client.evaluate(new JevRequest(request, config.model(), jevQuestions))<br>                .map(response -&gt; new Answers(<br>                        toDomain(answer(response, questions.urgency(), JevAnswer.Noul.class)),<br>                        toDomain(answer(response, questions.team(), JevAnswer.Choice.class)),<br>                        toDomain(answer(response, questions.severityScore(), JevAnswer.Score.class),<br>                                questions.severityScore())));<br>    }<br><br>    private static JevQuestion.Noul toJev(Question.Urgency question) {<br>        return new JevQuestion.Noul(question.instructions());<br>    }<br><br>    private static JevQuestion.Choice toJev(Question.Team question) {<br>        return new JevQuestion.Choice(question.instructions(), question.criteria());<br>    }<br><br>    // ...<br>}</pre><p>The one subtle mapping is the score. Jev keys score probabilities by <strong>level index</strong> (&quot;0&quot;, &quot;1&quot;, &quot;2&quot;), so the adapter turns each index back into a Severity through the same ordered list it sent:</p><pre>private static Answer.SeverityScore toDomain(JevAnswer.Score answer, Question.SeverityScore question) {<br>    List&lt;String&gt; options = question.options();<br>    Map&lt;Severity, Double&gt; probabilities = new LinkedHashMap&lt;&gt;();<br>    answer.probabilities().forEach((level, probability) -&gt;<br>            probabilities.put(Severity.valueOf(options.get(Integer.parseInt(level))), probability));<br>    return new Answer.SeverityScore(answer.score(), answer.confidence(), probabilities);<br>}</pre><p>That order is part of the contract. I first listed the most severe level at index 0, which made a <em>low</em> score mean a <em>severe </em>issue. Flipping it to MINOR → MAJOR → BLOCKER makes the numeric score read naturally: higher means worse.</p><p>A missing answer, or one of the wrong type, fails the Uni instead of propagating a half-filled result. Because the adapter takes its client in the constructor, its unit test passes a lambda as the client: no Quarkus, no HTTP, just the mapping.</p><h3>Step 5: reactive all the way down</h3><p>I made everything reactive: the REST client returns Uni&lt;JevResponse&gt;, the port returns Uni&lt;Answers&gt;, and the adapter just maps:</p><pre>return client.evaluate(new JevRequest(request, config.model(), jevQuestions))<br>        .map(response -&gt; new Answers(...));</pre><p>No extra dependency was needed: Quarkus REST Client handles Uni return types natively. Errors travel the same way: an HTTP error from Jev or a missing answer becomes a failed Uni, never an exception thrown halfway.</p><p>The one rule to remember: never call .await() outside tests. On the event loop Quarkus refuses to block and throws, which is a good guard rail.</p><h3>Step 6: the application layer</h3><p>The first use case is “create a ticket”. It is an inbound port, CreateTicketUseCase, implemented by a service that orchestrates the outbound ports:</p><ol><li>load the support teams;</li><li>build the questions from them and ask the assessor;</li><li>turn the answers into a ticket;</li><li>store it.</li></ol><pre>@Override<br>public Uni&lt;Ticket&gt; create(CreateTicketCommand command) {<br>    return supportTeams.findAll()<br>            .flatMap(teams -&gt; assessor.assess(command.request(), questionsFor(teams))<br>                    .map(answers -&gt; newTicket(command, teams, answers)))<br>            .flatMap(tickets::create);<br>}<br><br>private Ticket newTicket(CreateTicketCommand command, List&lt;SupportTeam&gt; teams, Answers answers) {<br>    return new Ticket(command.request(), command.submittedBy())<br>            .urgency(urgencyDecider.decide(answers.urgency()).level())<br>            .severity(answers.severityScore().mostLikely())<br>            .dispatch(teamDecider.decide(answers.team(), teams));<br>}</pre><p>Turning probabilities into decisions is domain logic, so it lives in small domain services. UrgencyDecider applies a threshold that comes from configuration (urgency.limit=0.9), injected through the constructor so a unit test can simply call new UrgencyDecider(0.9):</p><pre>@ApplicationScoped<br>public class UrgencyDecider {<br><br>    private final double limit;<br><br>    public UrgencyDecider(DecisionThresholds thresholds) {<br>        this.limit = thresholds.urgencyLimit();<br>    }<br><br>    public UrgencyDecision decide(Answer.Urgency urgency) {<br>        UrgencyLevel level = urgency.probability() &gt; limit ? UrgencyLevel.URGENT : UrgencyLevel.NORMAL;<br>        return new UrgencyDecision(level, urgency.probability());<br>    }<br>}</pre><p>On the outside, POST /api/tickets maps the HTTP DTO to a CreateTicketCommand, calls the use case and maps the Ticket back to a response DTO with 201 Created.</p><p>Input is validated with Hibernate Validator, and the endpoint is documented with MicroProfile OpenAPI annotations, so Swagger UI comes for free in dev mode. The mappers live in the presentation layer: the domain never sees a DTO, and a DTO never leaks a domain type.</p><h3>Step 7: using confidence, with a human in the loop</h3><p>Up to here the ticket always went to Jev’s top choice, even when Jev was unsure. But confidence is the main reason to use a model like this, so the dispatch got a second outcome: below a threshold (dispatch.confidence-limit=0.7) the ticket is <strong>not</strong> assigned. It goes to NEEDS_REVIEW, keeps Jev&#39;s choice as a suggestion, and a person picks the team.</p><p>TeamDecider makes that call, next to UrgencyDecider:</p><pre>public TeamDecision decide(Answer.Team answer, List&lt;SupportTeam&gt; teams) {<br>    SupportTeam chosen = teams.stream()<br>            .filter(team -&gt; team.id().equals(answer.chosenTeamId()))<br>            .findFirst()<br>            .orElseThrow(() -&gt; new InvalidAssessmentException(<br>                    &quot;Assessor chose an unknown support team: &quot; + answer.chosenTeamId()));<br><br>    return answer.confidence() &gt;= limit<br>            ? TeamDecision.assigned(chosen, answer.confidence())<br>            : TeamDecision.needsReview(chosen, answer.confidence());<br>}</pre><p>That introduced a rule that first lived only in comments: <em>if the ticket needs review, it has no assigned team but it does have a suggested one; if it was assigned automatically, there is nothing to suggest.</em></p><p>Comments do not stop anyone, so I moved the rule into the entity. Ticket has no setters for dispatchStatus, assignedTeam or suggestedTeam; they change only through two methods that keep the invariants:</p><pre>/** Applies the assessor&#39;s decision: assigns the chosen team or sends the ticket to human review. */<br>public Ticket dispatch(TeamDecision decision) {<br>    SupportTeam chosen = decision.chosenTeam();<br>    dispatchStatus = decision.status();<br>    assignedTeam = switch (decision.status()) {<br>        case ASSIGNED -&gt; chosen;<br>        case NEEDS_REVIEW -&gt; null;<br>    };<br>    suggestedTeam = switch (decision.status()) {<br>        case ASSIGNED -&gt; null;<br>        case NEEDS_REVIEW -&gt; chosen;<br>    };<br>    return this;<br>}<br><br>/** Manually assigns a ticket waiting for review. The assessor&#39;s suggestion is kept. */<br>public Ticket assign(SupportTeam team) {<br>    Objects.requireNonNull(team, &quot;team&quot;);<br>    if (dispatchStatus != DispatchStatus.NEEDS_REVIEW) {<br>        throw new TicketNotInReviewException(id);<br>    }<br>    dispatchStatus = DispatchStatus.ASSIGNED;<br>    assignedTeam = team;<br>    return this;<br>}</pre><p>TeamDecision rejects a null team in its compact constructor, so the team to assign or to suggest cannot be missing by construction. The switch expressions over the enum are exhaustive: a third status would not compile until it is handled. And the suggestion survives a manual assignment, so you can later compare what Jev proposed with what a human chose.</p><p><strong>A threshold alone was not enough.</strong> When I tried a deliberately vague request (“<em>Something is not working as expected</em>”, <em>a real and sadly frequent nightmare for anyone reading the ticket….</em>), Jev still answered with high confidence, and the ticket went to review only after I raised dispatch.confidence-limit all the way to 0.99.</p><p>Confidence tells you how sure the model is of <em>its</em> answer, not whether the question made sense. So I gave Jev a way out: every team question now carries one extra option, unclear (&quot;<em>the request is too vague or ambiguous to tell which team should handle it</em>&quot;). It is not a team: it lives in the domain, is added by Question.Team.criteria(), and cannot be assigned by hand. If Jev picks it, the ticket goes to review regardless of confidence, and the suggested team is the most probable <em>real</em> one from the probabilities.</p><pre>if (Question.Team.UNCLEAR_ID.equals(answer.chosenTeamId())) {<br>    SupportTeam leaning = mostProbable(answer.probabilities(), teams)<br>            .orElseThrow(() -&gt; new InvalidAssessmentException(<br>                    &quot;Assessor found the request unclear without ranking any support team&quot;));<br>    return TeamDecision.needsReview(leaning, answer.confidence());<br>}</pre><h3>Step 8: manual assignment and errors that mean something</h3><p>The review needs an endpoint: PUT /api/tickets/{id}/assignment with a body like {&quot;teamId&quot;: &quot;business&quot;}. Behind it, a second use case loads the ticket and the team, calls Ticket.assign and saves:</p><pre>@Override<br>public Uni&lt;Ticket&gt; assign(AssignTicketCommand command) {<br>    return tickets.findById(command.ticketId())<br>            .onItem().ifNull().failWith(() -&gt; new TicketNotFoundException(command.ticketId()))<br>            .flatMap(ticket -&gt; supportTeams.findById(command.teamId())<br>                    .onItem().ifNull().failWith(() -&gt; new SupportTeamNotFoundException(command.teamId()))<br>                    .map(ticket::assign))<br>            .flatMap(tickets::update);<br>}</pre><p>Each failure is a domain exception, and the presentation layer maps it to a status code with Quarkus’s @ServerExceptionMapper:</p><ul><li>TicketNotFoundException → <strong>404</strong>: no ticket with that id.</li><li>TicketNotInReviewException → <strong>409</strong>: the ticket is not waiting for review.</li><li>SupportTeamNotFoundException → <strong>422</strong>: the client sent a team that does not exist.</li><li>InvalidAssessmentException → <strong>502</strong>: Jev returned an answer the domain cannot use.</li></ul><pre>@ServerExceptionMapper<br>public RestResponse&lt;ErrorResponse&gt; ticketNotInReview(TicketNotInReviewException e) {<br>    return RestResponse.status(RestResponse.Status.CONFLICT, new ErrorResponse(e.getMessage()));<br>}</pre><p>The last two rows are worth a word. An unknown team id can come from the <strong>client</strong> (a typo in the assignment) or from <strong>Jev</strong> (a choice outside the options it was given). Same symptom, different culprit: the first is the caller’s fault (422), the second is an upstream failure (502, Bad Gateway). A dedicated InvalidAssessmentException keeps them apart.</p><h3>Testing strategy</h3><p>The hexagonal split pays off in the tests. There are three kinds, and only one of them starts Quarkus:</p><ul><li><strong>Domain</strong> (Ticket, deciders): plain unit tests, no Quarkus.</li><li><strong>Application services and the Jev adapter</strong>: ports replaced by lambdas, real in-memory repository, no Quarkus.</li><li><strong>REST API and Jev client</strong>: @QuarkusTest + REST Assured, with Jev stubbed by WireMock. This is the only layer that needs Quarkus.</li></ul><p>Most ports have a single method, so a fake is a lambda. Here the assessor returns canned answers and records the questions it was asked:</p><pre>RequestAssessor assessor = (request, questions) -&gt; {<br>    askedQuestions.set(questions);<br>    return Uni.createFrom().item(answers);<br>};<br><br>CreateTicketService service = new CreateTicketService(<br>        TEAMS, tickets, assessor, new UrgencyDecider(0.9), new TeamDecider(0.7));</pre><p>Assertions use AssertJ, which reads better than plain JUnit with sealed types:</p><pre>assertThat(response.answers().get(&quot;team&quot;))<br>        .isInstanceOfSatisfying(JevAnswer.Choice.class, a -&gt; {<br>            assertThat(a.choice()).isEqualTo(&quot;devops&quot;);<br>            assertThat(a.probabilities()).containsEntry(&quot;devops&quot;, 0.9);<br>        });</pre><p>The end-to-end tests stub Jev with WireMock, so they run offline and without an API key. That includes the review flow: a stub with a low confidence produces a NEEDS_REVIEW ticket, which the test then assigns through the API.</p><h3>Try it yourself</h3><p>The code is on GitHub: <a href="https://github.com/darkwings/jevving"><strong>github.com/darkwings/jevving</strong></a>. You need JDK 25 and a TypeSafe API key; the Gradle wrapper does the rest.</p><pre>git clone https://github.com/darkwings/jevving.git<br>cd jevving<br>export TYPESAFE_API_KEY=&lt;your key&gt;<br>./gradlew quarkusDev</pre><p>Then open a ticket:</p><pre>curl -s -X POST http://localhost:8080/api/tickets \<br>  -H &#39;Content-Type: application/json&#39; \<br>  -d &#39;{&quot;request&quot;: &quot;Our production site has been down for 20 minutes, the AWS load balancer returns 503 to every customer. Please help ASAP!&quot;, &quot;submittedBy&quot;: &quot;alice&quot;}&#39; | jq</pre><pre>{<br>  &quot;id&quot;: &quot;6f1c2a8e-3b7d-4e0a-9c55-2d8f1e4b7a10&quot;,<br>  &quot;request&quot;: &quot;Our production site has been down for 20 minutes, ...&quot;,<br>  &quot;submittedBy&quot;: &quot;alice&quot;,<br>  &quot;urgency&quot;: &quot;URGENT&quot;,<br>  &quot;severity&quot;: &quot;BLOCKER&quot;,<br>  &quot;dispatchStatus&quot;: &quot;ASSIGNED&quot;,<br>  &quot;assignedTeam&quot;: { &quot;id&quot;: &quot;devops&quot;, &quot;capability&quot;: &quot;AWS Dev-ops support for infrastructure problems&quot; },<br>  &quot;suggestedTeam&quot;: null<br>}</pre><p>To watch the review flow, restart with DISPATCH_CONFIDENCE_LIMIT=0.99 ./gradlew quarkusDev: <em>almost</em> every ticket will come back as NEEDS_REVIEW, ready to be assigned with:</p><pre>curl -s -X PUT http://localhost:8080/api/tickets/&lt;id&gt;/assignment \<br>  -H &#39;Content-Type: application/json&#39; \<br>  -d &#39;{&quot;teamId&quot;: &quot;developers&quot;}&#39; | jq</pre><p>The README has a longer guided tour, and Swagger UI is at <a href="http://localhost:8080/q/swagger-ui.">http://localhost:8080/q/swagger-ui.</a></p><h3>Limits and what could come next</h3><p>This is a proof of concept, so it has some serious limitations:</p><ul><li><strong>Everything is in memory</strong>: tickets are lost on every restart.</li><li><strong>Support teams are hard-coded</strong>, and there is no API to manage them: you edit the code and restart.</li><li><strong>No authentication</strong>: submittedBy (the user who submitted the ticket) is trusted as sent.</li><li><strong>Jev’s HTTP errors</strong> (401, 429, 529) still surface as 500, and there is no retry with backoff, which Jev’s docs recommend for 429 and 529.</li><li>Only the team choice uses confidence. Severity has a confidence too, and it is ignored.</li></ul><p>Natural next steps follow from the ports: a real database behind TicketRepository, a managed list of teams behind SupportTeamRepository that can be provided by a cache layer, retries in the Jev adapter and so on. None of them touches the domain. The one I find most interesting is measuring: every manual assignment records what Jev suggested and what a human chose, which is exactly the data needed to tune dispatch.confidence-limit.</p><h3>So, does the hype survive?</h3><p>Mostly. On my test tickets Jev routed the request to the right team, which is more than I can say for some humans on a Monday morning after a wild weekend.</p><p>What surprised me was its self-esteem: it was confident about everything, including a request that said nothing at all (“Something is not working as expected”). To get a human involved I had to push the confidence threshold up to 0.99, which is not the kind of threshold you tune so much as the kind you resort to.</p><p>In hindsight it is obvious that confidence measures self-assurance, not good judgment. It tells you how sure the model is of <em>its</em> answer, not whether the question made sense.</p><p>So I gave it a polite way to say “no idea”: the unclear option. A model that can answer &quot;devops&quot; is nice (<em>and if it would answer always “devops”… well, it would be a dream come true, but you’re not here for this, at least I guess</em>). Instead, amodel that can answer &quot;<em>I&#39;d rather not guess</em>&quot; is the one I would let near my support desk. Whether it uses that option as gracefully as I hope is the next experiment.</p><p>That’s all for now. And you…. are you ready to Jev?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f028660ad6e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dead Letter Society — a DLQ manager for Kafka]]></title>
            <link>https://medium.com/@franco.torriani/dead-letter-society-a-dlq-manager-for-kafka-e08275ee70f8?source=rss-be84e07af666------2</link>
            <guid isPermaLink="false">https://medium.com/p/e08275ee70f8</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[dead-letter-queue]]></category>
            <category><![CDATA[error-handling]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Franco Torriani]]></dc:creator>
            <pubDate>Sat, 06 Jun 2026 13:56:12 GMT</pubDate>
            <atom:updated>2026-06-06T19:58:18.691Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rAuHb_uCPeBfu2lD" /><figcaption>Photo by <a href="https://unsplash.com/@amaury_guti?utm_source=medium&amp;utm_medium=referral">Amaury Gutierrez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>You know it perfectly. Everyone knows that. When your Kafka consumer (or any consumer of any messaging service) fails, push the message into a Dead Letter Queue in order to analyze it and understand the failure.</p><p>Well, I bet that many of you actually did that. You configured your consumers to redirect failing messages to a dedicated topic, but… did you ever take a look at that topic?</p><p>Well, let’s be honest, the answer is: NO!</p><p>The thing is, we have many instruments available, from basic CLI to advanced UI like AKHQ, but probably the Dead Letter Topic remained an uncharted territory. This is the consideration that made me write an application dedicated explicitly to managing Dead Letter Queues (or topics).</p><p>You can find it here: <a href="https://github.com/darkwings/Dead-Letter-Society">https://github.com/darkwings/Dead-Letter-Society</a>. Give it a try and let me know if it works for you. Feel free to use it, fork it and, if needed, open a Pull Request to improve it (especially the UI part…).</p><blockquote>Disclaimer: it’s not production ready at the moment, but it’s almost there.</blockquote><p>In this post I want to share some background stories about this little side project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wDzNwaaGdZLJwi-A5tAAMA.png" /><figcaption>The Admin Dashboard</figcaption></figure><p>Let’s start with a simple description to share a common ground. Dead Letter Society is a web application for monitoring Kafka DLQs across multiple clusters, which allows users to:</p><ul><li>inspect schema-decoded payloads (Avro, Protobuf, JSON Schema via Confluent Schema Registry)</li><li>annotate messages with collaborative note threads and put messages <strong><em>under review</em></strong> before discarding or replaying</li><li>replay them to their original topic through a guarded wizard.</li></ul><p>It supports multi-cluster and multi-tenant, with both standalone and OIDC-federated auth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGDKEL6GdlY3XRVtJnDsyA.png" /><figcaption>Multi cluster support</figcaption></figure><p>The stack is Quarkus 3.x on the backend (JAX-RS, Hibernate ORM Panache, SmallRye JWT, Flyway), PostgreSQL, and a React + TypeScript frontend with TanStack Query, Zustand, and shadcn/ui.</p><p>This post is about the decisions that shaped the architecture.</p><h4><strong>Hexagonal Architecture — the Domain Stays Pure</strong></h4><p>The first structural call was to organize the backend as a strict hexagonal architecture:</p><p>domain/ ← pure Java objects, repository/service ports, zero framework deps</p><p>application/ ← use cases, inject ports via CDI @Inject</p><p>infrastructure/ ← Panache entities, Kafka adapters, REST resources</p><p>The domain package has no Quarkus annotations. No `<em>@Entity</em>`, no `<em>@Inject</em>`, no `<em>@Path</em>`. It only knows about domain concepts: <em>KafkaCluster</em>, <em>DlqConfig</em>, <em>DlqMessage</em>, <em>ReplayAuditRecord</em>.</p><p>This isn’t a post about hexagonal architecture. The internet is full of information on that topic, and I don’t want to waste your time with it. I’m just here to highlight some advantages and costs.</p><p>The advantage is clear, use cases are testable with pure Java mocks. Swapping the persistence layer or the Kafka client requires touching only the adapter. The domain model expresses intent without leaking persistence concerns.</p><p>The cost is clear as well, it adds ceremony. Every new feature requires a port interface even when there’s only one implementation. For a greenfield project, that’s a bet on future maintainability over short-term speed.</p><h4>The DLQ Configuration</h4><p>The most important concept is the <strong>DLQ Configuration</strong>. Basically, it is a configuration that represents the <em>monitoring contract</em> between the application and a DLQ topic on a Kafka Cluster.</p><blockquote>A <strong>DLQ Configuration</strong> is the <strong>contract</strong> between Dead Letter Society and a single DLQ topic: it defines which Kafka cluster and topic to watch, how often to fetch (or whether to fetch on demand), how long to retain messages, and which users can access them with what permissions. It’s also the authorization boundary, given that roles are assigned per DLQ Config, not globally.</blockquote><h4><strong>Track Offsets in the Database, not in Kafka</strong></h4><p>This one is non-negotiable for DLQ tooling: <strong>offsets are committed to the database, never to the Kafka broker</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PMNl9bZdGl5bP35UWFWDEA.png" /><figcaption>A DLQ Configuration, with failed messages to control</figcaption></figure><p>The naive approach (<em>use a consumer group and let Kafka track __consumer_offsets</em>) has a fatal flaw for a DLQ inspector. If you commit an offset, Kafka considers the message processed. But Dead Letter Society doesn’t process messages in the sense the original consumer did. It <em>*reads*</em> them. The user might want to re-read a message, replay it again, or audit the history. Committing offsets to Kafka permanently closes that door.</p><p>Instead, each <em>DlqConfig × partition</em> pair has a PartitionOffset record in PostgreSQL. Every fetch starts at <em>committedOffset + 1</em>. Deduplication uses <em>(dlqConfigId, partition, offset)</em> as a unique key in the messages table.</p><p>This also enables <strong>partition reconciliation</strong>: at the start of each fetch, the adapter compares the partitions known in the database against the live partitions from the broker. New partitions are seeded with offset -1 (<em>start from earliest</em>). Removed partitions are marked <em>INACTIVE</em>. If a gap appears, because Kafka compacted or expired messages between the committed offset and the earliest available, the system logs the gap and restarts from earliest rather than failing silently.</p><h4><strong>Decode Payloads at Ingestion, Store as JSONB</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hWGO9JK1fXBkJt40TgMw8A.png" /><figcaption>The message detail</figcaption></figure><p>Schema decoding happens once, at fetch time, and the result is stored as a JSONB column in PostgreSQL alongside the raw bytes.</p><p>The alternative, that is decode on every read, has obvious latency and Schema Registry availability implications. But there’s a subtler reason: schema evolution. If a schema is updated or deleted from the registry, messages fetched under the old schema remain readable. The decoded payload is a snapshot of what the message looked like at ingestion time.</p><h4><strong>SSE Over WebSockets for Notifications</strong></h4><p>Real-time notifications in DLS cover two scenarios: fetch completion (new messages are available) and message status changes visible to other users on the same detail page.</p><p>I chose <strong>Server-Sent Events</strong> over WebSockets for both.</p><p>SSE is HTTP/1.1-compatible, works through standard load balancers without upgrade negotiation, and is unidirectional, that is exactly what notifications need. The server pushes events; the client never sends back on the same channel. WebSockets add bidirectional complexity for a use case that doesn’t need it.</p><h4><strong>The Replay Wizard as a Safety Gate</strong></h4><p>Replay is the most consequential operation in the system. Publishing a malformed message back to a production topic can trigger the same consumer failure that put it in the DLQ in the first place, at scale, repeatedly.</p><p>The replay wizard is deliberately multi-step:</p><p>1. <strong>Preview: </strong>show the decoded payload and headers before anything is sent</p><p>2. <strong>Topic selection: </strong>resolve the target topic from priority order: explicit operator override → `x-original-topic` header → DLQ Config default</p><p>3. <strong>Payload edit + schema validation: </strong>if the operator edits the payload, it’s validated against the registered schema before the next step is enabled</p><p>4. <strong>Confirmation: </strong>final review with the exact topic and payload that will be published</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OrY138n5nD9_CHoveUouJQ.png" /><figcaption>The replay wizard</figcaption></figure><p>Payload editing is gated behind the OPERATOR role. Replay itself is OPERATOR and ADMIN. VIEWERs can read and annotate, nothing more.</p><p>Every replay, successful or failed, produces an immutable <strong><em>ReplayAuditRecord</em></strong></p><blockquote>who replayed it × when × target topic × was payload edited × attempt count × failure reason</blockquote><p>The Kafka producer uses raw `KafkaProducer` with `try-with-resources`, not reactive messaging channels. DLQ operations don’t fit the “fire and observe” pattern of reactive pipelines. Explicit send-and-wait-for-ack with a timeout is what you want when the result matters to the user standing at the confirmation screen.</p><h4><strong>RBAC With Two Independent Role Levels</strong></h4><p>Authorization in DLS has two orthogonal layers:</p><p><strong>Global role</strong> (ADMIN / USER): controls application-level access. Admins manage clusters, users, and see the dashboard. Regular users can only access DLQ configs they’ve been explicitly assigned to.</p><p><strong>DLQ role</strong> (VIEWER / OPERATOR): per-user, per-DLQ Config. Assigned by an admin. Controls whether a user can replay, edit payloads, or read-only annotate.</p><p>These layers don’t inherit. An ADMIN has implicit access to all DLQ Configs, but a USER with no DLQ assignments sees nothing. An OPERATOR role on one DLQ Config gives no permissions on another.</p><h4><strong>Building With AI as a Pair Programmer</strong></h4><p>This is maybe the more interesting part.</p><p>I am a seasoned Java developer, so I could write this application all by myself in some weeks without any problem (but with an ugliest UI for sure…).</p><p>At the same time, I wanted to make an experiment. Up to now, I used Claude Code to write applications on Swift, for mobile iOS apps, and Python (Agents), which are not my field of expertise (<em>I mean,</em> <em>I know Python, Swift, Typescript, Go but they’re not my main language</em>). In this case, I decided to stay in my comfort zone, the Java language, to drive the coding agent in the best possible way.</p><p>So, I built Dead Letter Society together with Claude Code. Not “I used AI to write boilerplate”. I mean, the entire application, from architecture decisions to Playwright E2E tests, was a pair-programming session.</p><p>The CLAUDE.md file at the root of the project is the operating manual for the AI pair: domain language, architectural conventions, gotchas, known limitations. It’s also the most useful onboarding document the project has.</p><p>Working this way surfaced something interesting: <strong>the quality of the AI’s output is a direct function of how well you’ve specified the domain</strong>.</p><p>In the planning phase, I instructed Claude Code to produce two specific files, <strong>DOMAIN.md</strong> and <strong>TERMS.md</strong>, linked then in CLAUDE.md file:</p><ul><li><em>DOMAIN.md</em>: a description of the domain of the application</li><li><em>TERMS.md</em>: a shared glossary, that let me Claude Code and me talk the same language without misunderstandings throughout the development. <em>Not to be confused with the DDD ubiquitous language, which is valid into a single bounded contexts.</em></li></ul><p>The investment I did during the planning phase in those two files, with canonical definitions of every entity and operation in the system, paid dividends, not because Claude needed them to write code, but because precise language eliminates drifts and ambiguity from both directions. Far from perfect, I know, but it is a direction that I want to explore further.</p><p>The biggest advantage wasn’t speed on individual tasks. It was that I could stay at the architecture level longer. I could describe what a use case should do and get a working implementation to review, rather than switching context between design and implementation every twenty minutes.</p><p>The limitation is real: <strong>AI-assisted development works best when you already know what you’re doing</strong>. <strong>It amplifies your decisions, including the bad ones.</strong> Every time I gave vague requirements, I got technically correct but misaligned code that needed rework.</p><p><strong>The lesson is clear: invest in precision upfront, even (especially) when working with AI.</strong></p><p>If you’ve fought with DLQ tooling in a Kafka-heavy environment, I’d be curious what your current setup looks like, and what this post missed.</p><p>Until next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e08275ee70f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create a faceless Instagram page using AI — part 1]]></title>
            <link>https://medium.com/@franco.torriani/create-a-faceless-instagram-page-using-ai-part-1-4005d290952c?source=rss-be84e07af666------2</link>
            <guid isPermaLink="false">https://medium.com/p/4005d290952c</guid>
            <category><![CDATA[digital-marketing]]></category>
            <category><![CDATA[instagram]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[marketing]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Franco Torriani]]></dc:creator>
            <pubDate>Sun, 05 Apr 2026 15:33:16 GMT</pubDate>
            <atom:updated>2026-04-05T15:33:16.935Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tQE3VRMy-iNiUxfB" /><figcaption>Photo by <a href="https://unsplash.com/@yaanapi?utm_source=medium&amp;utm_medium=referral">Yanapi Senaud</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This is the first part of a series of posts I want to dedicate to a specific theme: how to create a faceless Instagram page in an automated way.</p><p>This is a growing trend. Nowadays, if you’re not living under a rock and you use Instagram, especially if your feed includes AI or tech-related content, you’ve probably noticed a large number of pages summarizing news about AI, tech, or similar topics. These pages mainly use carousels, but also reels and stories, to make complex subjects accessible to non-technical audiences. Many of them even offer courses or guides on how to build this kind of page.</p><p>At a certain point, after seeing so many of these ads, a question came to mind: why should someone teach me how to do this?</p><p>Beyond being a software engineer, I’m essentially a nerdy guy, a curious mind with a strong interest in tech and AI. For me, the most satisfying way to explore a topic is to dive into it directly, relying on my existing knowledge and continuously pushing its boundaries. <em>Never stop learning, never!!</em></p><h3>Find a topic</h3><p>When you want to create this kind of Instagram page, first of all you have to find a topic that can generate interest on Instagram and on social media in general. Here you are my disclaimer: I consider this as an experiment. I do not want to monetize at the moment, so the choice was obvious: a page about software engineering (<em>something I can surely relate to</em>) and AI.</p><p>If you want to monetize, and you do not want to pay consultant, the best thing is to ask ChatGPT/Claude/Gemini to find niches with growth potential (<em>which I guess is the same thing the consultants do every day, so why pay for them?</em>). I think that this will be my next attempt and a topic for one of the next post of this series.</p><h3>First steps</h3><p>The core of a faceless Instagram page is to automate the creation of reels and posts, and we’ll get to that in a following post. Before that, you have to do one thing first: build your identity.</p><h4>The name of the page</h4><p>The name of the page is crucial, it’s the first element that presents your brand to the world. My idea was to find a name that represents the collaboration between a software developer and AI… and then it clicked: “<em>Dev and AI”</em>. What a fantasy…</p><p>Armed with the name, I first opened Google Gemini and asked…</p><blockquote>Create a logo for an Instagram page about software development and AI, called “dev.and.ai”. The colors should be black and shades of blue, light blue, and purple.</blockquote><p>And Nano Banana returned this image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MjZWpKv0C9y8vhNHLJAgEg.png" /><figcaption>The logo produced by Gemini</figcaption></figure><p>Beautiful, but not the best. I opened ChatGPT and asked the same question. This is what ChatGPT returned:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hrmANQ7pLP5GYS2JAznXHw.png" /><figcaption>The first logo</figcaption></figure><p>Very beautiful and modern, more focused than the Gemini version (<em>my taste, maybe you prefer the output of Gemini…</em>). So, I had name and the logo and I could proceed to create the Instagram page, but… hey, you cannot use dots in the Instagram handle!</p><p>I went back to ChatGPT and asked to update the logo removing the dots in the name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7gMYkpz_BI5SDY2WanmZBQ.png" /><figcaption>The official logo</figcaption></figure><p>Good! The Instagram handle had to reflect this update, so the final choice for the Instagram handle was <strong>dev_and_ai</strong>.</p><h4>The profile</h4><p>I had the name, the Instagram handle and the logo. The next thing to do was to create a bio. I asked ChatGPT to provide it, and it came out with many valid suggestions. I opted for this one:</p><blockquote>AI news that ships. ⚡<br>One daily post for developers who build, not just scroll.<br>Tools · APIs · Models · Code<br>↓ Today’s post</blockquote><h4>The palette of colors</h4><p>Wow. I had a name, a logo, and a bio. The last thing to do was to create “<em>a brand</em>” in order to make my post and reels consistent over time. I came back to ChatGPT and asked it to export the palette of colors used to create the logo depicted above and it returned this snippet.</p><pre>{<br> &quot;colors&quot;: {<br>   &quot;background&quot;: &quot;#0A0A0F&quot;,<br>   &quot;primary_blue&quot;: &quot;#2F80ED&quot;,<br>   &quot;secondary_cyan&quot;: &quot;#56CCF2&quot;,<br>   &quot;accent_blue_light&quot;: &quot;#7FDBFF&quot;,<br>   &quot;primary_purple&quot;: &quot;#9B51E0&quot;,<br>   &quot;secondary_purple&quot;: &quot;#7B61FF&quot;,<br>   &quot;text_primary&quot;: &quot;#FFFFFF&quot;,<br>   &quot;text_secondary&quot;: &quot;#A0A3BD&quot;<br> },<br> &quot;gradients&quot;: {<br>   &quot;main&quot;: &quot;linear-gradient(90deg, #2F80ED, #56CCF2, #9B51E0)&quot;,<br>   &quot;alt&quot;: &quot;linear-gradient(90deg, #2F80ED, #7B61FF)&quot;<br> }<br>}</pre><p>All the pieces were in place and it was time to pair with my coding agent buddy to create the content. But, before coding, I had one last thing to do.</p><h4>An agent skill to keep identity consistent</h4><p>Before starting to code, the last thing I had to do was create an agent skill to guide the coding agent in keeping the generated code and artifacts consistent with the chosen brand identity, both in terms of UI and UX. This is a crucial step, not only to generate content for social media but also for your coding activity in general. A branding skill ensures that every artifact generated by your coding agent stays aligned with your brand identity, preventing the “harlequin” effect, which could be fine for a personal blog, but not for a serious (<em>I hope</em>) brand.</p><p>I’m a paid Claude Code user (Pro account), so I opened Claude Code and used the skill-creator skill to build the “dev_and_ai” branding skill. I provided Claude Code with:</p><ul><li>the name of the Instagram page</li><li>the aim of the page</li><li>the font to be used for the slides (Poppins)</li><li>the color palette shown above</li></ul><p>It then generated the skill, which I saved at the user level on my Mac to be reused across different projects.</p><p>At that point, everything was finally in place to start coding, but that’s a topic for the next post.</p><p>In the meantime, you can enjoy my Instagram page at <a href="https://www.instagram.com/dev_and_ai/">https://www.instagram.com/dev_and_ai/</a>.</p><p>Until next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4005d290952c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Read It Now: another iOS app with Claude Code]]></title>
            <link>https://medium.com/@franco.torriani/another-ios-app-with-claude-code-433ba9bd5f8b?source=rss-be84e07af666------2</link>
            <guid isPermaLink="false">https://medium.com/p/433ba9bd5f8b</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[claude-code]]></category>
            <dc:creator><![CDATA[Franco Torriani]]></dc:creator>
            <pubDate>Sun, 22 Mar 2026 19:04:15 GMT</pubDate>
            <atom:updated>2026-04-16T17:34:15.031Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j8fqUAHlZyUC_Ijn" /><figcaption>Photo by <a href="https://unsplash.com/@tomhermans?utm_source=medium&amp;utm_medium=referral">Tom Hermans</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>Update April 9th 2026, the app is now available on the Apple App Store! Yeah! Take a look: </em><a href="https://darkwings.github.io/ReadItNow-site/index.html">https://darkwings.github.io/ReadItNow-site/index.html</a></p><h4>Why did I need to write a new app?</h4><p>In my daily life I work as a software engineer, but in my spare time there are two things I love most:</p><ul><li>playing guitar (<em>and listening to metal music</em>)</li><li>reading (and I mean, I read <em>a lot</em>… more than 50 books per year, mostly thrillers and crime novels)</li></ul><p>With my first iOS app (I blogged about it <a href="https://medium.com/@franco.torriani/claude-code-for-ios-development-my-first-app-e58e2a04d102">here</a>), I tried to solve my biggest problem on stage as a live musician. With my second app, I decided to build something to manage my book library and track what I read. Seems easy, right?</p><p>Well, not at all. If you’re on Instagram and follow some Bookstagram accounts, you’ll notice, beyond a very polished and aesthetic style, that the things mentioned most are:</p><ul><li>the (insane) number of books read per year, with a dedicated review for each one</li><li>the (insane) number of pages read per day</li><li>(at the end of the year) a recap of the most beautiful books read</li></ul><blockquote>You may now be asking yourself, what the hell is Bookstagram? According to Gemini AI overview, “Bookstagram is a dedicated, visual community on Instagram where book lovers (<a href="https://www.google.com/search?q=Bookstagrammers&amp;client=safari&amp;hs=bgE&amp;sca_esv=e5620ef2793957f5&amp;rls=en&amp;sxsrf=ANbL-n5F7xljTW4bOUIwbeF4Eb4ysV7AqQ%3A1774202647915&amp;ei=Fy_AaYjQN6qmi-gP75Dl8QU&amp;ved=2ahUKEwibxfv9i7STAxXU1wIHHdZ0At0QgK4QegQIARAC&amp;uact=5&amp;oq=what+is+Bookstagram&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiE3doYXQgaXMgQm9va3N0YWdyYW0yBhAAGAcYHjIGEAAYBxgeMgYQABgHGB4yBhAAGAcYHjIIEAAYBxgKGB4yBhAAGAcYHjIIEAAYgAQYywEyCBAAGIAEGMsBMggQABiABBjLATIIEAAYgAQYywFIqhJQjAhYihBwAXgAkAEAmAFnoAGEBqoBAzguMbgBA8gBAPgBAZgCBaAC-gLCAgoQABiwAxjWBBhHwgINEAAYgAQYsAMYQxiKBcICDhAAGLADGOQCGNYE2AEBwgITEC4YgAQYsAMYQxjIAxiKBdgBAcICBxAjGLACGCfCAgcQABiABBgNmAMAiAYBkAYSugYGCAEQARgJkgcDNC4xoAeYSrIHAzMuMbgH8wLCBwUyLTQuMcgHHoAIAA&amp;sclient=gws-wiz-serp">Bookstagrammers</a>) share photos, reviews, and content about books. It functions as a global, niche book club featuring #bookstagram, reading challenges, and aesthetic photos of books, commonly covering genres like fiction and romance.”</blockquote><h4>Basic requirements</h4><p>So my app shouldn’t just be a simple log of books read since day one — it should also let users track their reading progress for books read in the past, each with a proper rating, in order to feed a “<em>statistics</em>” section they can show off to make themselves look good in the <em>Bookstagram</em> world.</p><p>Another decision I had to make was about the backend. Do I really need one? I wanted to keep costs at a minimum, so in the end the decision was easy: no backend at all, but extensive use of <a href="https://developer.apple.com/documentation/SwiftData">SwiftData</a> and iCloud synchronization across the user’s devices.</p><p>Risky? Perhaps. If a user deletes the app and its data, the library is gone — but there are real advantages that simplify a lazy developer’s life:</p><ul><li><strong>Data stays private.</strong> Without a backend API deployed on a cloud provider, data lives in the user’s private space, protected directly by Apple’s infrastructure. This is a strong mitigation for any privacy concern (GDPR and similar regulations are very strict, and nobody wants to deal with the consequences of a data breach).</li><li><strong>No authentication needed</strong>, beyond an Apple ID — which is another big relief.</li></ul><p>Another thing to consider was the look &amp; feel. As I said before, Bookstagram is a really polished world. Accounts are carefully curated, with a consistent aesthetic throughout all posts and reels. A book tracker app could have all the features in the world, but first and foremost it should be beautiful and stylish. I’m not entirely sure I managed to reach that goal — my taste in UI/UX is, let’s say, questionable (<em>even in the AI era, when there are tools that can design an app for you, if your design taste is that of a goat — as is my case — you can’t produce a “beautiful” app</em>) but, hey, I did my best!</p><p>So, my bullet points were:</p><ul><li>allow users to track and rate any book, even ones read in the past</li><li>keep data private</li><li>make a good-looking app</li></ul><p>…all with limited knowledge of Swift and the iOS SDK. The obvious choice was to pair up with Claude Code.</p><h4>Read It Now with Claude Code</h4><p>I started writing my app, called <strong>Read It Now</strong>, at the end of December 2025, and submitted it to the App Store on March 21st. Three months may seem like a long time for an app built with the help of an AI agent, but keep in mind that I only worked on it on weekends — and not every weekend. The actual effort was about 15 working days.</p><p>Wait, wait — I can hear you already. <em>“Fifteen days to write a mobile app with an AI coding agent? Are you serious?”</em> Well… actually, yes, it took time. That brings me to the following consideration:</p><blockquote>if someone tells you that you can write any app with an AI agent in 5 minutes, they’re kidding you. You can certainly build a proof of concept in minutes, good enough to impress friends, family, or investors — but for a real app, with all the features and guardrails in place, you need to take your time.</blockquote><p>AI can help you (and it helps <em>a lot</em>), but to ship a real mobile app, web application, or micro-service, you need to take your time, do the necessary refinements and rework, and make sure it behaves exactly the way you want. Don’t trust AI blindly — at least not yet. That said, an app like <strong>Read It Now</strong>, packed with features, would have taken a minimum of two months in the pre-AI era. I completed it in 15 working days, so the productivity boost is clear.</p><h4>The evolution of Claude Code</h4><p>The other thing I want to point out is that over these three months, Claude Code has taken some giant leaps forward.</p><p>I tried many skills and tools throughout the project, but in the final days I ended up working with basically just one skill — <a href="https://claude.com/plugins/superpowers">Superpowers</a> — plus two custom Swift development skills I built with <a href="https://github.com/anthropics/skills/blob/main/skills/skill-creator/SKILL.md">Skill Creator</a>.</p><p>In the early days, at the beginning of 2026, I extensively tested several spec-driven development tools. In particular, I tried <a href="https://github.com/github/spec-kit">Spec Kit</a> to give Claude Code a framework for producing a plan, the related tasks, and then implementing them. I wasn’t satisfied with the results at all. Spec Kit is a GitHub tool, but it’s not very well integrated with the GitHub ecosystem.</p><p>I tested other spec-driven tools as well — both skills and full React applications running locally — but none of them passed the test.</p><p>In the meantime, the Claude Code team <a href="https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md">shipped many fantastic features</a> at an insane pace, so in the end I found myself most comfortable just using Claude Code as-is, leveraging its built-in support for planning and task organization, with the Superpowers skill for brainstorming new features and refining plans.</p><blockquote><strong>Keep it simple.</strong> If someone tells you that you need to collect thousands of skills and plugins to build anything with Claude Code, they’re lying to you. Claude Code now handles brainstorming, planning, and task management in an amazing way, without any external frameworks or skills. Spec-driven development can be handled entirely with what Claude Code gives you out of the box.</blockquote><h4>The last steps to bring a mobile app to life</h4><p>After days of work, your app is ready to be deployed to millions of users, but first you have to upload it to the App Store and deal with the bureaucracy. This is the part I hate most. You have to:</p><ul><li>prepare screenshots of your app, which should be engaging, and you have to prepare them for all languages you decided to support.</li><li>prepare titles and descriptions</li><li>prepare a privacy policy (<em>even if Read It Now is a very simple app that keeps its data private on the Apple Cloud, it uses Google Books API to get book information and it uses in-app purchase</em>).</li></ul><p>Probably my next app will be something that will automate these steps, but for Read It Now, I had to take a more manual approach… well, manual but with the help of AI.</p><h4>The screenshots for App Store</h4><p>I took the screenshots of the app and put them in an iPhone wireframe. After that, I told Claude Code to prepare two Canva projects, one for the Italian store and the other for all other countries, with 7 images each. Each image should have an engaging title and subtitle. I installed Canva MCP, and Claude did all the stuff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bk5HkE9FA_TduCh0MP3SZQ.png" /></figure><p>An incredible feature of the Superpowers plugin is that it allows you, during the brainstorming phase, to visually see the result of what you’re asking. It starts a local web server, and by accessing it with a web browser, you can actually preview the result of your requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-3cgVy9G-3D2aJNwcT-hig.png" /></figure><p>This is the final result (actually, the first of the seven images downloaded from Canva). <em>I told you, I’m not an UX guy, my taste is very, very bad.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*3e0WpDjXF5JVzB9YD0ne0Q.png" /></figure><h4>The privacy policy</h4><p>The other critical thing you have to provide before submitting an app is the privacy policy. There are many online services that aim to simplify the production of a privacy policy compliant to all regulations out there, but I thought “<em>Hey, those services probably use AI to compose the policy you pay to download, so why the hell should I pay to use an AI service when I’m already paying an AI service like Claude Code?</em>”</p><p>So I asked Claude Code to prepare a website for my app, a site that should include not only some screenshots of the app, the list of features, and a support page, but also a complete privacy policy, in Italian and English.</p><p>With Superpowers skills, exactly like what happened for Canva projects, I was actually able to preview the website locally and see it growing under my eyes.</p><p>I also asked for a free deployment of the site, and Claude Code suggest me to use GitHub Pages. At the moment I do not care about a dedicated web domain for my app, so GitHub Pages is enough. This is the repo:</p><p><a href="https://github.com/darkwings/ReadItNow-site">GitHub - darkwings/ReadItNow-site: Public website for ReadItNow app</a></p><p>and this is the web page, deployed with a GitHub action, available on GitHub pages (<em>ok, ok, I say it again, I’m not an UI/UX guy, and there is no AI that can do anything about it…</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCvBAgX2QsflJxZvnC68ig.png" /></figure><h4>Insights</h4><p>Claude Code gives you the valuable command /insights. With this command, Claude analyzes your usage patterns of the tool giving you useful suggestions on how to improve your interaction with the coding agent.</p><p>For example, the first execution of the /insights command pinpointed a wrong way I used to drive Claude to solve a race condition on the code. <em>Pay attention: it emphasizes a problem with my interaction with the coding agent, which causes a long time in the resolution, it did not deal with the technical aspects of the problem itself.</em></p><p>Give it a try, you won’t be disappointed.</p><h4>Final considerations</h4><p>This is a little story of the genesis of a mobile app. In the last months, Claude Code evolved in an impressive way, and, in the end, I found myself comfortable with a <em>stripped-to-the-bone</em> instance of the coding agent, triggering parallel sessions on different git worktrees, with a limited number of skills and one MCP server. Basically, my advices, for what they are worth, are:</p><ul><li>keep your coding agent setup as simple as possible (also the Claude Code creator <a href="https://x.com/bcherny/status/2007179832300581177?lang=it">states that</a>)</li><li>take your time, do not pretend your app is ready in minutes. Plan it with care, implement it, refine it then start the loop again until you and/or your stakeholders are satisfied.</li></ul><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=433ba9bd5f8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Digital mixers and AI]]></title>
            <link>https://medium.com/@franco.torriani/digital-mixers-and-ai-279f813e7599?source=rss-be84e07af666------2</link>
            <guid isPermaLink="false">https://medium.com/p/279f813e7599</guid>
            <category><![CDATA[behringer]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[digital-audio]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Franco Torriani]]></dc:creator>
            <pubDate>Sat, 14 Feb 2026 19:35:23 GMT</pubDate>
            <atom:updated>2026-02-15T00:28:56.217Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ozuw3QINom9I3x7b" /><figcaption>Photo by <a href="https://unsplash.com/@ayanangshu?utm_source=medium&amp;utm_medium=referral">Ayanangshu Biswas</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you read my <a href="https://medium.com/@franco.torriani/claude-code-for-ios-development-my-first-app-e58e2a04d102">previous post</a>, you know that I wrote an iOS app to control the monitors of my Behringer XR18 mixer. The app is currently under review by the Apple App Store team.</p><p>Surely, the app simplifies interaction with the mixer when it comes to personal monitoring, but it has nothing to do with mixing the final sound for the audience.</p><h3>The dream</h3><p>A few days ago, I started thinking how great it would be to produce a mix with the help of AI.</p><p>This could truly be a dream come true. You open the Claude Desktop app (or ChatGPT or whatever application you prefer) and simply chat:</p><blockquote>I have to mix a four-piece band: voice, guitar, bass, and drums. I have 9 input channels: voice, guitar, bass, and then drums on kick, snare, two toms, floor tom, and cymbals. Please produce an initial mix and equalization based on recognized best practices. Name the inputs accordingly with the list above. Then assign the following names to the monitors: “Joe” (singer), “Tommy” (guitar), “Daniel” (bass), and “Will” (drums).</blockquote><p>Based on that, your faithful LLM:</p><ul><li>initializes the input channels with appropriate gain staging and basic EQ</li><li>initializes the monitors with a sensible starting balance</li></ul><p>For example, Joe’s monitor (the singer) would emphasize the vocal in his personal mix.</p><p>With all of this in place, the possibilities are endless. You could continue chatting with your LLM, saying things like:</p><ul><li>“There’s too much low end on the bass — make it clearer.”</li><li>“Raise the bass slightly in Tommy’s monitor.”</li></ul><p>Science fiction? Not at all. It’s all about giving your LLM the right tools, and that means… MCP.</p><h4>Meet the XR18 MCP server</h4><p>The missing link between an LLM and a digital mixer is <a href="https://modelcontextprotocol.io/docs/getting-started/intro">Model Context Protocol</a>, introduced by Anthropic. So I partnered once again with Claude Code to write my first MCP server.</p><p>The Behringer X-Air series can be controlled via the Open Sound Control (OSC) protocol over UDP. I had recently studied this protocol, which allowed me to guide Claude Code toward the right online resources to retrieve all the necessary technical details.</p><p>Given that, choosing the technology stack for the MCP server was straightforward. Python provides solid support for building an MCP server. On top of that, the python-osc library greatly simplifies OSC integration.</p><p>Claude Code and I did a bit of planning and, in less than an hour, the first version of my MCP server was ready.</p><p>You can find it here:</p><p><a href="https://github.com/darkwings/OSC_MCP">GitHub - darkwings/OSC_MCP: MCP Server for Open Sound Control Protocol</a></p><p>The server is in initial stage. It is free to use, so feel free to checkout and give it a ride. You can also submit a PR if you want.</p><p>See you next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=279f813e7599" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Long running agents — my thoughts]]></title>
            <link>https://medium.com/@franco.torriani/long-running-agents-my-thoughts-ccde742129b1?source=rss-be84e07af666------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccde742129b1</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[ai-autonomous-agents]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Franco Torriani]]></dc:creator>
            <pubDate>Tue, 06 Jan 2026 17:34:35 GMT</pubDate>
            <atom:updated>2026-01-06T17:41:51.016Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Long running agents — my thoughts</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JQMfmFIo7ztWo4SB" /><figcaption>Photo by <a href="https://unsplash.com/@elico5?utm_source=medium&amp;utm_medium=referral">Elise Coates</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Some days ago, doing some research, I stumbled upon a very interesting article by Anthropic</p><p><a href="https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents">Effective harnesses for long-running agents</a></p><p>When implementing complex projects — where you work on many features, possibly over several days — there is a significant risk that the agent (whether Claude Code, Gemini CLI, or similar tools) will lose focus and fail to fully meet the expectations defined during the planning phase.</p><p>This happens because context is finite and, despite all precautions (summarization, etc.), at some point the agent no longer remembers what it did in the early stages of the project, which features it implemented, or how those features were implemented.</p><blockquote>The core challenge of long-running agents is that they must work in discrete sessions, and each new session begins with no memory of what came before. Imagine a software project staffed by engineers working in shifts, where each new engineer arrives with no memory of what happened on the previous shift. Because context windows are limited, and because most complex projects cannot be completed within a single window, agents need a way to bridge the gap between coding sessions.</blockquote><p>In fact, during one of my recent tests, I ran into exactly this problem and noticed that Claude Code was heading in a different direction than what had been agreed upon during the planning phase. I had Claude Code write a plan.md file and then I simply told it, “<em>Ok, now start Phase X of the plan</em>” without providing the agent with the necessary information (that is, the required context) to proceed in the right way.</p><p>This is a real issue, and if you are developing an application and want it to be more than just a proof of concept — or something to show to your friends late at night — it is a serious one.</p><p>An experienced developer can usually spot this and, to some extent, take back control of the situation. That same situation, however, can easily spiral out of control if someone without sufficient experience relies entirely on AI and on the promise that AI can do everything autonomously.</p><p>Sure, AI can operate autonomously, but without proper oversight and without managing the agent’s operation correctly, the AI ends up shooting in all directions (regardless of how much effort you put into developing prompts, skills, or commands). At that point, all we can do is hope it happened to shoot in the right direction.</p><p>While researching this topic, in addition to the Anthropic article that sparked these reflections, I also came across some interesting resources that I encourage you to check out:</p><ul><li><a href="https://github.com/anthropics/claude-quickstarts/tree/main/autonomous-coding">https://github.com/anthropics/claude-quickstarts/tree/main/autonomous-coding</a>, the companion Github repo of the Anthropic article</li><li><a href="https://www.youtube.com/watch?v=lGWFlpffWk4">https://www.youtube.com/watch?v=lGWFlpffWk4</a> where the difference between the long prompt approach and the feature-based approach are crystal clear</li><li>Automaker: <a href="https://github.com/AutoMaker-Org/automaker">https://github.com/AutoMaker-Org/automaker</a></li><li>Auto Claude: <a href="https://github.com/AndyMik90/Auto-Claude">https://github.com/AndyMik90/Auto-Claude</a></li></ul><p>Personally, I think that in my next projects (at the moment, nothing more than a hobby), I will introduce one of these tools into my workflow.</p><p>Basically, we have to become the managers of AI, rather than letting AI manage us. As developers, we are accustomed to working with a (hopefully) well-defined and well-planned set of features, which are merged into the main branch only after thorough reviews and testing. This is exactly the mindset we all need to apply when working with AI.</p><p>See you next time</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccde742129b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Claude Code for iOS Development: my first app]]></title>
            <link>https://medium.com/@franco.torriani/claude-code-for-ios-development-my-first-app-e58e2a04d102?source=rss-be84e07af666------2</link>
            <guid isPermaLink="false">https://medium.com/p/e58e2a04d102</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[digital-audio]]></category>
            <dc:creator><![CDATA[Franco Torriani]]></dc:creator>
            <pubDate>Mon, 29 Dec 2025 21:17:34 GMT</pubDate>
            <atom:updated>2026-02-22T18:37:41.113Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YlgmXsfyaGaIcmLr" /><figcaption>Photo by <a href="https://unsplash.com/@duo?utm_source=medium&amp;utm_medium=referral">Alberto Duo</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><strong><em>Update — February 22, 2026: m</em></strong><em>y app is finally available on the App Store. It’s called PersonalMonitorBuddy (yes, without spaces — my mistake!).<br>If you’re an X-Air user, give it a try!</em></p><h3>The abstract</h3><p>I’ll be honest — when I first started experimenting with Claude Code for iOS projects, I was skeptical. My background is mostly in backend development, and the idea of relying on an AI assistant to write Swift code felt like a leap of faith.</p><p>I was wrong.</p><p>Over the past few days, I’ve used Claude Code to build my first iOS app from scratch, and what I discovered changed how I think about my entire workflow. I’m not talking about generating snippets to copy and paste — I mean actual collaboration: architecture decisions, implementation, debugging, all the way to App Store configuration.</p><p>In this article, I’ll share what it’s actually like to work this way. What Claude Code handles well, where it struggles, and whether it makes sense for developers who aren’t iOS specialists but want to ship something real.</p><h3>The problem</h3><p>Generally, unless you’re just trying to impress friends and followers, an app should solve a real life problem, and my “problem” was the following (<em>ok, ok, I know that there are many people that has </em><strong><em>real</em></strong><em> problems these days compared to my simple issue, so let’s take the term </em><strong><em>problem</em></strong><em> “cum grano salis”</em>)</p><p>I play guitar (and also sing) in a hard-rock cover band and, for the same band, I also play the role of sound engineer. We have our own audio mixer, the Behringer XR18, and I’m able to use it quite well with its companion app, X-Air Edit for Mac.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*nq8D8qLcjmclO1wB.jpg" /><figcaption>The beautiful Behringer XR18</figcaption></figure><p>Moreover, we play exclusively with in-ear monitor, which simplifies a lot the life on the stage. Wedges are evil, and if you know.. you know!</p><p>The problem arises whenever we’re on stage, playing live, and a bandmate tells me (<em>remember, I am the also sound engineer, while trying to play guitar and sing…</em>) that he needs a quick regulation of the volume of his personal monitor. The easiest way for me is to have my MacBook near on stage and, with X-Air Edit app, perform a quick regulation of his monitor levels.</p><p>Why I use a MacBook and X-Air Edit also on stage? Well, mainly for two reasons. First, the Behringer iPad app sucks (at least for me) and second, Mixing Station app is really, really great but it is…. too much and too complicated for a quick fix.</p><p>In the end what I need was a quick way to regulate the volume of the inputs in the monitor right on the stage, in the fastest way possible.</p><p>Given that, some days ago, I decided to write my own app to manage personal monitors on stage, an app that has <strong>that one</strong> specific feature, implemented <strong>in the simplest way possible</strong>.</p><h3>The problem, part 2</h3><p>I am a software engineer, and I’ve been working with Java, Kafka, AWS and other backend technologies for years, developing web applications and microservices in various environments, from finance to health care. Sadly, it’s not possible to write an iOS app with those tools (at least, the mobile app itself) and learn Swift is definitely out of scope at the moment.</p><p>But, wait… we’re in the middle of the AI era. AI Agents are able to prototype an application in hours, in any language and I know this perfectly because I’m a paid Claude user but, until now, I used Claude Code only for my personal stuff and to have some help for my work business.</p><p>So, as you may have already guessed, I decided to use Claude Code to develop my own “Personal Monitor Buddy” iOS app.</p><h3>First steps</h3><p>First of all, I decided to focus on my mixer. In the future I will add support for more brands, but the most important thing is to solve <strong>MY</strong> problem, and therefore control <strong>MY OWN mixer</strong>.</p><p>AI can give you a hand and do all the dirty work for you, but I’m quite obsessed to know how things actually work, so I did some research and I discover that Behringer X-AIR series can be remotely controlled via Open Sound Control protocol (more <a href="https://opensoundcontrol.stanford.edu/spec-1_0.html#introduction">here</a>, <a href="https://behringer.world/wiki/doku.php?id=x-air_osc">here</a>, and <a href="https://cdn.mediavalet.com/aunsw/musictribe/hmivS7F05kKSJlWDYPGLpA/agTKkSIWS0y1bJl97YZEjg/Original/X%20AIR%20Remote%20Control%20Protocol.pdf">here</a>). Being able to access, and comprehend, the documentation helped a lot to fix some errors made by Claude Code during the process, as we’ll see in the following.</p><h3>Sub-agents and Skills</h3><p>Needless to say, I saw this project as a mean to use some Claude Code advanced features like sub-agents and skills, so I did some research on how this feature works and how to use them inside my project. In the end, I developed two skills, ios-modern-architect and ios-swift-development, and one agent called swift-expert and I will link the related md files at the end of this post.</p><h3>The UI</h3><p>I am a backend developer, so I’m confortable with stuffs that are usually non exposed to the public but, in this case, we’re talking about a mobile app, so thinking about UI and UX was not an option.</p><p>To gather some inspiration on the UI I visited <a href="https://dribbble.com/">Dribbble</a> and looked to some iOS app concepts and designs. I discover this beautiful concept by <a href="https://dribbble.com/arounda">Arounda</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/0*I8RttLEB8qQ7aZxD" /><figcaption>Credits: Arounda (<a href="https://dribbble.com/arounda">https://dribbble.com/arounda</a>)</figcaption></figure><p>I found this concept amazing and I decided that my app would implement that color scheme.</p><h3>CLAUDE.md and the starting prompt</h3><p>The internet is full of suggestions about writing CLAUDE.md files so I won’t bother with that and I’ll post a link to it at the end of the article. As many others do, I let Claude write that file explaining what I wanted to achieve and Claude did a great job, listing all the technical details and the constraints that my app should satisfy.</p><p>Armed with my two ios skills and one agent, and a scaffold project prepared by XCode, here you are the prompt I gave to Claude Code to start the work.</p><pre>The Personal Monitor Buddy application allows users to independently adjust <br>channel volumes on their personal stage monitor (IEM or wedge monitor). <br>The digital mixer brands to support are: Behringer (X-Air, Wing, and X32/M32 <br>series), Soundcraft (UI and VI series), Midas (HD, X32/M32, and X-AIR series), <br>PreSonus (StudioLive III), and Allen &amp; Heath (dLive, iLive, Avantis, GLD, <br>SQ, QU).<br><br>On launch, the app should present a screen where the user selects <br>the mixer to connect to (brand first), then allows selection of the supported <br>mixer model, and finally chooses the aux bus for volume control. <br>The brand selection screen should display brand names using their <br>respective logos, while the mixer selection should include an image <br>representing each mixer.<br><br>The UI must be simple and engaging, starting from brand selection. <br>Channel fader controls must be intuitive and immediate. <br>This app should do one thing only and enable doing it in the simplest <br>way possible. For immediate comprehension, the panel should display channel <br>names as configured on the mixer.<br><br>Connection to the mixer occurs over the local network, so permission to scan for mixers on the Wi-Fi network must be handled.<br><br>Support for various mixers should be available via in-app purchase. <br>Gift codes should also be supported (in case I want to let friends use the app). A 10-minute free trial must be available, after which the app disconnects from the mixer.<br><br>Let&#39;s start with Behringer X-Air mixers.<br><br>Propose a plan and submit it to me for review.</pre><p>Claude Code switched to plan mode and did the job beautifully, proposing a very reasonable 4 points plan that I read and accepted. Here you are the main points, without all the details:</p><p><strong>Phase 1</strong>: Foundation &amp; Setup (Objective: Project structure, localization, base models, initial UI)</p><p><strong>Phase 2</strong>: X-AIR Networking (Objective: OSC communication with Behringer X-AIR mixers)</p><p><strong>Phase 3</strong>: Fader UI &amp; Control (Objective: Fader and channel control interface)</p><p><strong>Phase 4</strong>: In-app purchase and App Store submission (Objective: trial and pro version, testing with Test Flight and submission to iOS App Store)</p><h3>The Plan and the actual development</h3><h4>Phase 1</h4><p>Now, we had a plan and all the instruments in place, so I told Claude to start its work from Phase 1. It prepared all the basic views and the workflow. In this phase, the only thing I had to do was to fix some navigation and localization issues.</p><h4>Phase 2</h4><p>With the basic views outlined, we (Claude and I) started the implementation of the networking. Here Claude developed a very specific solution for Behringer X-AIR series and I drove its work to a more general solution. Basically I told Claude to define a contract (an interface) and provide an implementation of the contract based on user choice, also known as Factory Pattern.</p><p>The most important thing is that I did not pass to Claude (simply I forgot to do it) any reference to OSC protocol, but it did its job beaufully and retrieved all the informations it needs with a web search, implementing an OSC client from zero. Anyway, Claude did two mistakes:</p><ol><li>The OSC port exposed by X-AIR mixers is 10024. I don’t know why, Claude decided that the reference port was 10023, so the first connection attempts failed. I told Claude to use the 10024 and we’re done.</li><li>Claude did not implement correctly the retrieval of bus names (a bus, also known as A<strong>ux</strong>, is the actual output that feed in-ear monitors and/or wedges). The thing is that the OSC protocol declares for the channels commands like <em>/ch/01/…</em> with the channel number padded to two characters while the bus commands are like <em>/bus/1/…</em>, with the bus number <em>NOT</em> padded to two chars. Claude developed the protocol assuming all numbers (channels and buses) were padded to two characters. I read the documentation of the protocol, read the code developed by Claude and explained the agent how to fix the error.</li></ol><h4>Phase 2.1</h4><p>Before Phase 3, I forced Claude to review the UI and the basic palette of colors deployed in Phase 1. At this point, the UI developed by Claude was elegant but very simple. I passed to Claude Code the Dribbble screenshots of the UI I want to achieve (in term of colors) and the agent revamped the UI to satisfy my request.</p><p>This is a screenshot of the final app, but it’s basically the output of this phase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*fw9uCH1MI6dEDEEAtcBAGg.png" /><figcaption>Step 1: choose your brand</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*7_uPcPBHdJwxSfR_XGVeyg.png" /><figcaption>Step 2: look for your mixer and connect</figcaption></figure><h4>Phase 3</h4><p>With mixer discovery in place, Claude and I could focus on the <strong>Aux Selection View</strong> and the <strong>Fader View</strong>, updating the initial basic implementation of Phase 1, basically based on simple placeholders.</p><blockquote>For those who are not practical with digital mixers, the <strong>faders</strong> are the knobs that allow users to regulate output volume, for front of house and for monitors.</blockquote><p>As I said before, this app aims to do one thing, and to do it in the simplest possible way. Once user choose the mixer and connects to it, the only thing the user can do is to select the Aux he/she wants to manage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*SOeedbqI3ylFadJfb1CX3w.png" /><figcaption>Step 3: select the aux you want to manage</figcaption></figure><p>Here you can see that the name of the bus is clearly visible, so it’s easy to choose which Aux to manage (for example, I am the main singer, so I would choose Singer 1). Once user selects the Aux, we can proceed to the most important view of the application, the Fader view, the core of this application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*6IWQdpK1XXw7iy_34iZBRw.png" /><figcaption>Step 4a: you can now manage volumes of all inputs in your monitor</figcaption></figure><p>With this view, the user can finally regulate freely the volume of all the inputs in his/her ears (or in the stage wedge). I tried to make faders as big as possible, but I decided to offer another option to users. By tapping the “Buttons” button in the upper right corner, the view changes into a simple one, for an even more faster control of the inputs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*xUHrbNSrxdH9Z7FozlA3Tw.png" /><figcaption>Step 4b: a simpler way to control the volume of the inputs</figcaption></figure><p>The Fader view is the core of the application and it was the most difficult to implement, given the synchronization of two different ways to regulate each input. Claude and I struggled a lot with the +/- buttons and, in the end, we decided to differentiate the outcome of the action on the buttons:</p><ul><li>between -10db and 10db the buttons implement a little variation of the volume (0.5db), as this area is the one in which the user (probably) desires to have more control and needs a fine grained resolution</li><li>under -10db, the buttons apply a more aggressive variation of 5db.</li></ul><p>Doing this way, it was possible to synchronize correctly the faders and the buttons.</p><p>Here you are a GIF of the application on my laptop. See how it interacts with the official app in a beautiful way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*YWgaPawAruRvXnff7a1xiQ.gif" /><figcaption>PM Buddy in action</figcaption></figure><h3>The best feature in my opinion</h3><p>I saved the best for last. One of the biggest complain I have with Mixing Station app (which is, in my humble opinion, the best app to manage audio mixers) is that, once you choose to connect to a mixer as Personal Monitor, changing the Aux to control is a real pain. So I wanted to make this switch as easy as to drink a cup of tea.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*-1MkZ188AukybPBsrxMv9g.gif" /><figcaption>Aux switch made simple, finally!!!</figcaption></figure><p>In the video above, you can see how it’s easy to switch from an Aux to another. For me, a little sound engineer on stage that needs to regulate levels for all my bandmates, this feature is pure gold.</p><h3>The submission on the App Store</h3><p>Basically the app is complete and locally it works well, both on simulator and on the devices I own, as you saw on the video above. The only thing that’s missing is the submission to the App Store, but I think that this is the boring part and I won’t bother you with this stuff. At the time I’m writing this article, the burocracy still is not completed (I’m waiting for a paper from my municipality) and I cannot submit the app yet. I will be back sooner when the App is available on the store.</p><p>The app will be free to use.</p><h3>Summarizing</h3><p>Writing a iOS app with Claude was very fun. Claude took care of all the boring stuff and let me concentrate on the features to implement. It did many errors (the Fader view was a nightmare actually) but I managed to fix them, driving the implementation in a proper way.</p><p>I have plenty of ideas for other mobile apps, and I think that Claude and I will be a very good couple.</p><p>As I promised, here you are the skills and agents file I used in this project.</p><p><a href="https://github.com/darkwings/PersonalMonitorBuddy-claude/tree/main">GitHub - darkwings/PersonalMonitorBuddy-claude: Claude agents and skills used for PersonalMonitorBuddy app</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e58e2a04d102" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling errors in Kafka consumers]]></title>
            <link>https://medium.com/@franco.torriani/handling-errors-in-kafka-consumers-ced0b3bad211?source=rss-be84e07af666------2</link>
            <guid isPermaLink="false">https://medium.com/p/ced0b3bad211</guid>
            <dc:creator><![CDATA[Franco Torriani]]></dc:creator>
            <pubDate>Sun, 07 May 2023 16:50:16 GMT</pubDate>
            <atom:updated>2023-08-14T20:01:05.983Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DlkSE7MDMggjMc9W" /><figcaption>Photo by <a href="https://unsplash.com/@korolevalkv?utm_source=medium&amp;utm_medium=referral">Veronika Koroleva</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Writing a Kafka consumer in Java seems easy, write an infinite loop, call <em>poll()</em> method and you’re done. Is it really true? Well…. not at all. There are many things you have to consider.</p><p>Let’s start with a simple consumer loop.</p><pre>var service = Executors.newFixedThreadPool(1);<br>service.submit(() -&gt; {<br>  while (true) {<br>      var records = consumer.poll(Duration.of(100, MILLIS));<br>      for (var record : records) {<br>          // do some stuff with the records read<br>      }<br>  }<br>});<br></pre><p>A loop like the one shown above can be enough if you’re preparing a tutorial for dummies or a simple PoC but if you’re writing an enterprise application you cannot simply loop through the records. In real life there are many edge cases that will make that loop crash, leaving you with unanswered questions and, sadly, unhappy customers.</p><blockquote>Before we begin, keep in mind that in this article is not an introduction to Kafka and so I will take for granted many things. I assume you know what Kafka is, and I will assume that you have clear in mind how producers and consumers work, what is a consumer group, what is the <em>offset</em> and what it means to <em>commit the offset</em>.</blockquote><p>So, without further ado, let’s take a tour through all the bad things that can happen to your consumer and how to face them:</p><ul><li>wake up</li><li>rebalance</li><li>recoverable errors</li><li>unrecoverable errors</li><li>deserialization errors</li><li>too many time between subsequent calls of <em>poll()</em> method</li><li>poison pills</li></ul><p>To keep the discussion as simplest as possible, in the snippets we’re going to show let’s assume that we’re using automatic offset commit and that the consumer is part of a consumer group.</p><h3>Wake up</h3><p>Technically speaking, “waking up” is not an error, but nevertheless is something you have to manage, and you can do it with two simple steps:</p><ul><li>add a shutdown hook and call <em>Consumer.wakeup()</em> method in it</li><li>catch a <em>WakeUpException</em> in the poll loop and… do nothing.</li></ul><p>Let’s see how to do it with some code.</p><pre>var consumer = new KafkaConsumer&lt;String, String&gt;(props());<br>consumer.subscribe(List.of(&quot;source-topic&quot;));<br><br>final Thread mainThread = Thread.currentThread();<br><br>// This is the shutdown hook to add in order to manage<br>// a clean exit of your application<br>Runtime.getRuntime().addShutdownHook(new Thread() {<br>    public void run() {        <br>        consumer.wakeup();<br>        try {<br>            mainThread.join();<br>        } catch (InterruptedException e) {<br>        }<br>    }<br>});<br><br>var service = Executors.newFixedThreadPool(1);<br>service.submit(() -&gt; {<br>  try {<br>      var records = consumer.poll(Duration.of(100, MILLIS));<br>      for (var record : records) {<br>          // do some stuff with the records read<br>      }<br>  }<br>  catch (WakeUpException e) {<br>      // clean exit<br>  }<br>  catch (Exception e) {<br>      log.error(&quot;Unexpected error&quot;, e);<br>  }<br>  finally {<br>      consumer.close(); // this will also perform an offset commit, if needed<br>  }<br>});</pre><h3>Rebalance</h3><p>Same as before, this is not an error but it’s a normal situation in the lifecycle of a consumer. Rebalance can happen when a consumer joins or leaves a group (<em>a crashed consumer can be considered as a consumer that left the group</em>)</p><p>In any case, your consumer can be notified of what happened and you can manage assignation and revocation of partitions.</p><pre>var consumer = new KafkaConsumer&lt;String, String&gt;(props(),<br>    new RebalanceHandlerListener() {<br><br>        public void onPartitionsRevoked(Collection&lt;TopicPartition&gt; partitions) {<br>            // Manage revocation of partitions.<br>            // If you&#39;re committing offset manually, you should have<br>            // to perform a commit here<br>        }<br><br>        public void onPartitionsAssigned(Collection&lt;TopicPartition&gt; partitions) {<br>            // Here you&#39;re notified of the assignment of partitions.<br>            // This is a good place to seek to a specific offset for that<br>            // partitions, if saved externally (in a database)<br>        } <br>    }  <br>);<br>consumer.subscribe(List.of(&quot;source-topic&quot;));<br><br>final Thread mainThread = Thread.currentThread();<br><br>// This is the shutdown hook to add in order to manage<br>// a clean exit of your application<br>Runtime.getRuntime().addShutdownHook(new Thread() {<br>    public void run() {        <br>        consumer.wakeup();<br>        try {<br>            mainThread.join();<br>        } catch (InterruptedException e) {<br>        }<br>    }<br>});<br><br>var service = Executors.newFixedThreadPool(1);<br>service.submit(() -&gt; {<br>  try {<br>      var records = consumer.poll(Duration.of(100, MILLIS));<br>      for (var record : records) {<br>          // do some stuff with the records read<br>      }<br>  }<br>  catch (WakeUpException e) {<br>      // clean exit<br>  }<br>  catch (Exception e) {<br>      log.error(&quot;Unexpected error&quot;, e);<br>  }<br>  finally {<br>      consumer.close(); // this will also perform an offset commit, if needed<br>  }<br>});</pre><p>Clean shutdown and rebalances can be considered as normal events in the lifecycle of a consumer. Let’s talk now about handling errors, the main topic of this article.</p><h3>Errors</h3><p>The aim of a consumer is, well, to consume messages. The processing of those messaging will usually be something different than some logging, so for sure you will incur in some errors, and not all errors are the same. Basically you can have errors that are:</p><ul><li>recoverable (related to a temporary condition), or</li><li>unrecoverable.</li></ul><h4>Recoverable errors</h4><p>A transient, or <strong>recoverable</strong>, error while processing a message could be caused by a network glitch or any kind of a temporary problem in your infrastructure (<em>as an example, let’s suppose that, in your consumer, you have to store your message in a database and a temporary network error makes the DB unreachable for some seconds</em>). It’s a wide class of errors but, in general, we can say that, for such kind of errors, it makes sense to think about a retry strategy that will allow your application to consume again the message later when, hopefully, the transient problem is solved.</p><p>The most important thing to keep in mind about recoverable (or <em>retryable</em>) errors is that they are not caused by the message itself but they’re totally due to external conditions.</p><h4>Unrecoverable errors</h4><p>In the context of Kafka consumer, we can define an unrecoverable error as an error that is always reproducible and that cannot be fixed in any way. The most common case is a message that is <em>syntactically</em> valid but is <em>semantically</em> wrong.</p><p>Let’s think about a JSON message that describes the coordinates of an object (a car in motion).</p><pre>{<br>  &quot;car_id&quot;:&quot;23874028472354&quot;<br>  &quot;latitude&quot;: -1242642.23482<br>  &quot;longitude&quot;: -90213.294851239<br>}</pre><p>This message represents a negative position. Its content is clearly wrong and it will be wrong even if consumed again in a later moment.</p><p>For this kind of errors it’s not useful to think about a retry strategy so we can call them unrecoverable errors. The only thing you can do is to discard them, or send them to a specific topic (more about that in a while), and go on with the following messages.</p><h4>Deserialization errors</h4><p>A special kind of unrecoverable error is the deserialization error. In this case you are dealing with a message that your consumer is not able to read.</p><p>Let’s suppose that you’re expecting to receive an AVRO message but someone else published, on the topic your application is consuming from, a String message. In a situation like that the deserializer throws an exception and that exception is then rethrown by <em>poll()</em> method. If not caught, it will make your application crash.</p><p>You can limit this kind of problems applying a strict control on the publishers, granting access to topic to specific producers implementing authentication and authorization policies but, in the end, you have absolutely no control on what a producer publishes, so you have to manage this kind of errors in a proper way.</p><h4>Actual error handling</h4><p>Let’s extend the code snippets above adding all the necessary stuff to manage the errors we described.</p><pre>var consumer = new KafkaConsumer&lt;String, String&gt;(props(),<br>    new RebalanceHandlerListener() {<br><br>        public void onPartitionsRevoked(Collection&lt;TopicPartition&gt; partitions) {<br>            // Manage revocation of partitions.<br>            // If you&#39;re committing offset manually, you should have<br>            // to perform a commit here<br>        }<br><br>        public void onPartitionsAssigned(Collection&lt;TopicPartition&gt; partitions) {<br>            // Here you&#39;re notified of the assignment of partitions.<br>            // This is a good place to seek to a specific offset for that<br>            // partitions, if saved externally (in a database)<br>        } <br>    }  <br>);<br>consumer.subscribe(List.of(&quot;source-topic&quot;));<br><br>final Thread mainThread = Thread.currentThread();<br><br>// This is the shutdown hook to add in order to manage<br>// a clean exit of your application<br>Runtime.getRuntime().addShutdownHook(new Thread() {<br>    public void run() {        <br>        consumer.wakeup();<br>        try {<br>            mainThread.join();<br>        } catch (InterruptedException e) {<br>        }<br>    }<br>});<br><br>var service = Executors.newFixedThreadPool(1);<br>service.submit(() -&gt; {<br>  try {<br>      var records = consumer.poll(Duration.of(100, MILLIS));<br>      for (var record : records) {<br>          if (record.value() == null) {<br>              // record with null value should be produces by a deserializer<br>              // able to manage serialization errors<br>              continue;<br>          }<br>          try {<br>              // processing stuff, throwing specific exceptions based<br>              // on the type of error detected<br>          }<br>          catch (RecoverableException e) {<br>              retryManager.manage(record); <br>          }<br>          catch (UnrecoverableException e) {<br>              dlqManager.manage(record);<br>          }<br>      }<br>  }<br>  catch (WakeUpException e) {<br>      // clean exit<br>  }<br>  catch (Exception e) {<br>      log.error(&quot;Unexpected error&quot;, e);<br>  }<br>  finally {<br>      consumer.close(); // this will also perform an offset commit, if needed<br>  }<br>});</pre><p>The <em>props()</em> method is shown below</p><pre>private Properties props() {<br>    var p = new Properties();<br>    // mandatory properties, such as bootstrap server, group.id and so on<br>    p.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ErrorAwareDeserializer.class);<br>    return p;<br>}</pre><p>The snippets above introduces some new components and concepts we’re going to describe.</p><ul><li>When you process a message you have to choose how to manage a processing error, distinguishing a temporary situation, that can be recovered later, from an error that cannot be recovered in any way. This distinction can be formalized with two different types of exception: <em>RecoverableException</em> and <em>UnrecoverableException</em>.</li><li><strong>retryManager</strong> is a component that will manage recoverable errors. There are various strategies applicable to this case and there are many suggestions available on internet. As an example, the <strong>retryManager</strong> can schedule the publication of the message on the source topic with a specific delay, even better with exponential backoff (that means a delay that grows after each attempt). Consider to limit the number of retries: this component can store in-memory the number of attempts for a specific message and when this number reaches a given limit, it can send the message to Dead Letter Topic (DLT, or Dead Letter Queue, more on this shortly). Maybe I will write an article about retry strategies later, it’s an interesting topic I faced in the past and I developed some interesting solutions.</li><li><strong>dlqManager </strong>is a component that will manage unrecoverable errors, sending the message to a specific topic call <strong>Dead Letter Topic</strong> (or Dead Letter Queue if you prefer). This topic can be analyzed later with specific tools in order to understand the origin of the problem.</li><li><strong>ErrorAwareDeserializer</strong> is a custom deserializer that will manage serialization error (<em>keep in mind that in this article we are considering serialization errors related to the value of the message, e.g. the payload, but also the key can generate such kind of problems</em>). The most common case of such an error is when you expect to consume an AVRO message but your application receives something that is not AVRO. Let’s implement an example of a deserializer that can manage this kind of error.</li></ul><pre>class ErrorAwareDeserializer&lt;T extends SpecificRecord&gt; implements Deserializer&lt;T&gt; {<br>    private Deserializer&lt;T&gt; delegate;<br><br>    public ErrorAwareDeserializer() {<br>    }<br><br>    public ErrorAwareDeserializer(Deserializer&lt;T&gt; delegate) {<br>        this.delegate = setupDelegate(delegate);<br>    }<br><br>    @Override<br>    public void configure(Map&lt;String, ?&gt; configs, boolean isKey) {<br>        if (this.delegate == null) {<br>            setupDelegate();<br>        }<br>        this.delegate.configure(configs, isKey);<br>    }<br><br>    @Override<br>    public T deserialize(String topic, byte[] data) {<br>        try {<br>            return delegate.deserialize(topic, data);<br>        } catch (Exception e) {<br>            log.error(&quot;Error deserializing message from topic {} - message content is: &#39;{}&#39;. &quot; +<br>                    &quot;Record should be sent to message hospital&quot;, topic, new String(data));<br>            return null;<br>        }<br><br>    }<br><br>    public void setupDelegate() {<br>        try {<br>            this.delegate = setupDelegate(new KafkaAvroDeserializer());<br>        } catch (Exception e) {<br>            throw new IllegalStateException(e);<br>        }<br>    }<br><br>    private Deserializer&lt;T&gt; setupDelegate(Object delegate) {<br>        return (Deserializer&lt;T&gt;) delegate;<br>    }<br>}</pre><p>The core of this deserializer is the <em>deserialize()</em> method that intercepts deserialization errors returning <em>null</em>. This is the reason why, in the consumer loop above, we checked <em>record.value()</em> to be not null. Even if this deserializer is tailored on handling AVRO failures, the idea can be applicable in many other cases.</p><p>One further option to complete the custom deserializer could be to send the message, along with its metadata (topic, offset, partition, timestamp etc.), to a specific topic called <strong>Message Hospital</strong>, that can be consumed later with specific tools in order to analyze what caused the producer to publish an unreadable message.</p><h3>Long processing</h3><p>Another kind of problems we have to manage is related to how Kafka interacts with clients. There is a lot if documentation available on internet that explains the protocol in a thorough way. To put is shortly, the consumer is asked to poll the cluster for new messages periodically and the time between two subsequent calls of <em>poll()</em> method should be less than the value of the consumer property <em>max.poll.interval.ms</em>. If Kafka does not receive a <em>poll()</em> request within this interval, it will consider the consumer as dead and will trigger a rebalance.</p><p>You can fix this problem in 2 ways:</p><ul><li>monitor your code and try to understand why the processing of the messages takes too much time.</li><li>tweak your consumer to fetch a small number of messages for each call of the <em>poll()</em> method. You can tweak this behavior in terms of the number of messages read for each poll request, setting the consumer property <em>max.poll.records</em> at a value lower than the default one. Another option is to set the maximum number of bytes read for each call, setting the consumer property <em>fetch.max.bytes</em> to a value lower than the default one.</li></ul><p>Of the two given options, the first one is clearly the way to go. Tweaking a consumer to solve this problem is nothing more than a workaround.</p><h3>Poison pills</h3><p>The worst kind of errors your consumer can face it’s the Poison Pill. <em>A Poison Pill is the king of unrecoverable errors</em>, because it is a message that</p><ul><li>is syntactically valid</li><li>is semantically valid</li><li>doesn’t cause deserialization error</li></ul><p>but it will <strong>always</strong> make your application crash.</p><p>So, any valid message can be a Poison Pill. In the Java world, the tipical case of Poison Pill is a message that generates an <em>OutOfMemoryException</em>. When your application consumes such kind of message, it crashes without committing the offset. At the restart of the application, the message is consumed again and your application is likely to crash again, becoming trapped in a loop that never ends.</p><p>If you think about it, Deserialization Errors and Poison Pills are similar. In both cases, your consumer is not able to handle a message and you have to bypass it in some way. Anyway there is a big difference between them: while a deserialization error is likely caused by a producer that published something wrong on the topic, <strong>the Poison Pill unveils a bug of the consumer</strong>. Why? Because it is a perfectly valid and readable message, but its processing makes your application crash.</p><p>Given that it’s a bug…. you have to solve it. In the meantime, the only thing you can do to prevent an infinite crash of your consumer, and only if you can tolerate some message loss, is to manually advance the offset of the consumer group to bypass the poisonous message.</p><p>There are actually other advanced strategies to manage a Poison Pill, leveraging Kafka Streams, but they are out of the scope of this article.</p><h3>Conclusion and disclaimer</h3><p>In this article we saw how to manage errors while consuming messages from Kafka. The code shown in this article <strong>is not production ready</strong>, so use it <em>cum grano salis</em> but I hope it can give you an idea about how to manage errors in your new ad shiny consumer.</p><p>Hope it can help and see you next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ced0b3bad211" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PRS SE Paul’s Guitar]]></title>
            <link>https://medium.com/@franco.torriani/prs-se-pauls-guitar-fda7930c0c93?source=rss-be84e07af666------2</link>
            <guid isPermaLink="false">https://medium.com/p/fda7930c0c93</guid>
            <category><![CDATA[musical-instruments]]></category>
            <category><![CDATA[guitar]]></category>
            <category><![CDATA[prs-guitars]]></category>
            <category><![CDATA[guitar-review]]></category>
            <category><![CDATA[music]]></category>
            <dc:creator><![CDATA[Franco Torriani]]></dc:creator>
            <pubDate>Sun, 22 Aug 2021 14:23:17 GMT</pubDate>
            <atom:updated>2021-10-10T13:24:05.471Z</atom:updated>
            <content:encoded><![CDATA[<p>There is a PRS guitar which is almost unknown or, let’s say, it has less appeal that the classic and well known Custom 22 and Custom 24. This guitar is the Paul’s Guitar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sUM50gvvaOSAOOAHP13vRg.jpeg" /><figcaption>My PRS SE Paul’s Guitar</figcaption></figure><p>At the beginning of this year I bought the ‘economic’ version, the SE Paul’s Guitar, the one in the picture above. It’s a great guitar, believe me.</p><p>I won’t bother you with technical details about woods, pickups, neck, fretboard etc. A simple google search will satisfy all your questions. I will tell you instead about the unique features that make me love it.</p><h4>The neck</h4><p>If you look at the specs you can read that the neck has a “wide fat” profile. I have no big hands, so I thought that this kind of shape could give me some troubles… well, no! The neck is actually fatter and wider than the one of my other guitars (2012 Gibson Les Paul Studio and Yamaha Revstar) but it gives me absolutely no troubles in playing, it’s very, very comfortable.</p><h4>The bridge</h4><p>The bridge is actually the same that is used in the very expensive core model made in the U.S.A. so it’s a real plus to find such an amazing piece of musical engineering in an “economic” model.</p><p>It has no saddles, so you could think that there could be some problems in intonation. Actually, no, any problem at all.</p><h4>The pickups</h4><p>Both the pickups support coil-tap through two dedicated toggles placed between the knobs (<em>the toggles are very small, it’s quite difficult to operate on them while playing</em>). The coil-tap works very, very well. When you activate this feature, the fat sound of the humbuckers is transformed into a sound that is very similar to a single coil guitar…. ok, ok, stop it!!! it’s not exactly like a Strat, it’s not so twangy but it’s close.</p><p>The killer feature, in my opinion, is that the coil-tap have no side-effects on the final volume. It means that you can pass, during a song, from humbucker to single-coil sound without losing volume. Killer feature, really!!</p><p>By the way, if you want to listen to my PRS (and to my Les Paul Studio) in action, here’s the link of my YouTube channel:</p><p><a href="https://www.youtube.com/channel/UCnhfdPUdmispvNcwW00cYAw">https://www.youtube.com/channel/UCnhfdPUdmispvNcwW00cYAw</a></p><p>So, this is my opinion on this fantastic guitar. It’s the SE model, it’s not the core U.S.A. model, but I absolutely love it. Feel free to share your experience with this guitar if you want. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fda7930c0c93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kafka Streams: a special sink configuration]]></title>
            <link>https://medium.com/codex/kafka-streams-a-special-sink-configuration-4e116564fc07?source=rss-be84e07af666------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e116564fc07</guid>
            <category><![CDATA[avro]]></category>
            <category><![CDATA[kafka-streams]]></category>
            <category><![CDATA[event-sourcing]]></category>
            <category><![CDATA[schemaregistry]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Franco Torriani]]></dc:creator>
            <pubDate>Sun, 22 Aug 2021 10:33:29 GMT</pubDate>
            <atom:updated>2021-08-22T16:14:28.564Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Vf3tcv_ArmImPQ0x" /><figcaption>Photo by <a href="https://unsplash.com/@tolga__?utm_source=medium&amp;utm_medium=referral">Tolga Ulkan</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>One (sink) topic, many AVRO types</h4><p>This won’t be a tutorial about Kafka Streams. Internet is full of them, and some are really, really good. This won’t be a tutorial about the Schema Registry either. Same as before, google for it and you can find all the answers you need.</p><p>Actually, this article describes a very specific configuration of a stream processor and implies a good knowledge of Kafka Streams and how to integrate it with Confluent Schema Registry when you want your stream processor to consume, process, and produce AVRO messages.</p><p>What I want to achieve is to show you how to create and configure a stream processor that can produce different types of AVRO messages on the sink topic. It’s a very specific use case, but can be useful in some cases.</p><p>Let’s go.</p><h4>A simple sink</h4><p>When you configure a sink on a Kafka Streams topology you usually write something like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb5eb3f383b76b77612cad418d3d58af/href">https://medium.com/media/fb5eb3f383b76b77612cad418d3d58af/href</a></iframe><p>Easy, isn’t it?</p><p><em>Actually, if you don’t have special requirements, you can configure the default serializers and deserializers directly in the stream processor configuration, as explained </em><a href="https://docs.confluent.io/platform/current/streams/developer-guide/datatypes.html#configuring-serdes"><em>here</em></a><em>. In this case, the </em><em>to() method could be called omitting the </em><em>Produceddirective.</em></p><h4>A less simple sink</h4><p>Let’s say now that you want your stream processor to produce AVRO messages and include Schema Registry support in your stream processor (this has many benefits and it’s out of the scope of this article to enumerate them, so please read <a href="https://www.confluent.io/blog/schema-registry-kafka-stream-processing-yes-virginia-you-really-need-one/">this</a>). To do so, you have to configure a specific AVRO serializer and use it in the configuration of your topology.</p><p>Let’s use a support class for the purpose.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82e2c7e6ff375d4166028a4039114e62/href">https://medium.com/media/82e2c7e6ff375d4166028a4039114e62/href</a></iframe><p>This class wraps all the informations about a topic: the name, the key SerDe (serializer/deserializer) and the value SerDe. The configureValueSerDe() method allows us to configure the value SerDepassing the url of the schema registry.</p><p><em>In this article, I’m assuming that the key is always a String, and we only need to configure the value serializer, but configuring also the key as an AVRO object is straightforward.</em></p><p>You can use this class in your stream processor to configure the sink.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/adbd70a194636b4fc247c24089a68bfc/href">https://medium.com/media/adbd70a194636b4fc247c24089a68bfc/href</a></iframe><p>With this topology in place, you stream processor can publish AVRO messages.</p><p>Ok, now the interesting stuff!</p><h4>One sink, many types</h4><p>Let’s say now that you want your stream processor to produce different type of messages on the destination topic. This is a requirement that makes sense in many use cases (see <a href="https://www.confluent.io/blog/put-several-event-types-kafka-topic/">here</a> and <a href="https://www.confluent.io/blog/multiple-event-types-in-the-same-kafka-topic/">here</a>) but it seems to be difficult to achieve in a Kafka Streams topology, especially when you use the beautiful Kafka Streams DSL… but is it really that difficult?</p><p>Actually, it’s quite simple, and it’s a matter of a single line of code. Here it is the revised TopicSerDe class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a41a420f8784d3cf79269557e269de3/href">https://medium.com/media/8a41a420f8784d3cf79269557e269de3/href</a></iframe><p>As you can see, the updated configureValueSerde() method adds to the SerDe configuration also the naming strategy of the schema stored in the Schema Registry. With this configuration in place your stream processor will use TopicRecordNameStragegyto store the subjects on the Schema Registry, and you can produce all the required type of messages you need without the restrictions of the default schema naming policy used by Kafka Streams by default (TopicNameStrategy, which actually means “one type per topic”).</p><h4>DISCLAIMER</h4><p>I’m not saying at all that is wrong to design a solution in which you want to publish only one type of message per topic. In my daily work, this is the default design I use, because of its clarity and because of the better support you can obtain from the other tools of the Confluent Platform (especially ksqlDB, which is a really amazing tool).</p><p>There are cases though in which it’s preferrable to publish different types of messages on a topic. The articles linked above explain this concept clearly, but I give my 2 cents to make it more clear.</p><p>Let’s think about the events related to an Orderof an e-commerce web site. If you model them as Java objects with AVRO support you will have OrderCreated, PaymentAccepted, OrderShipped and so on. If you want these events to be consumed in the right order by the downstream consumers, you must publish them on a dedicated topic, carefully selecting the partition key in order to have them published in the same partition (and you know for sure that Kafka guarantees the order of messages at partition level).</p><h4>A repo</h4><p>Here you can find an example of the use of this configuration</p><p><a href="https://github.com/darkwings/event-sourced-kstream">https://github.com/darkwings/event-sourced-kstream</a></p><p>I hope this little article will be useful. See you next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e116564fc07" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/kafka-streams-a-special-sink-configuration-4e116564fc07">Kafka Streams: a special sink configuration</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>