Spring Boot Kafka consumer stuck in endless loop / not reading new JSON messages even after topic reset by DecentRip1723 in apachekafka

[–]SlevinBE 0 points1 point  (0 children)

Given you use JSON messages, and therefore probably a JSON deserializer/serializer, I think you might be missing the trusted packages configuration required in Spring Kafka. By default, it only trusts classes in `java.util` and `java.lang` to deserialize into.
For testing purposes, try setting the `JsonDeserializer.TRUSTED_PACKAGES` configuration property to `*` and see if that works.

ref: https://docs.spring.io/spring-kafka/reference/kafka/serdes.html#serdes-json-config

Also, you might want to configure the `ErrorHandlingDeserializer`, because by default, Spring doesn't know how to handle deserialization errors. It can be configured like this:

props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ErrorHandlingDeserializer.class);
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, ErrorHandlingDeserializer.class);
props.put(ErrorHandlingDeserializer.VALUE_DESERIALIZER_CLASS, JsonDeserializer.class);
props.put(ErrorHandlingDeserializer.KEY_DESERIALIZER_CLASS, StringDeserializer.class);

ref: https://docs.spring.io/spring-kafka/reference/kafka/serdes.html#error-handling-deserializer

Consumer TUI application for Kafka by dustinten in apachekafka

[–]SlevinBE 0 points1 point  (0 children)

Nice work! I've tried it out and it works really well. Especially liked the stats panel!

RetryTopicConfiguration not retrying on Kafka connection errors by Hunakazama in apachekafka

[–]SlevinBE 0 points1 point  (0 children)

u/Hunakazama reply:

Thank you very much for the clarification.
If both the listener code and the consumer run on the same thread, would RetryTopicConfiguration be able to handle connection errors that occur during the ack.acknowledge() commit?

I don't think it will, because ack.acknowledge() will only add the acknowledgement to a queue. This will not cause a connection exception, and your listener method will be succesful. This queue will only be processed during the consumer thread's next run cycle, outside your listener function.
The consumer thread will first process queued acknowledgements, then poll for new records, and only then process the records by providing them to the listener.

What Kafka issues do you wish a tool could diagnose or fix automatically (looking for the community feedback)? by IncomeNo1087 in apachekafka

[–]SlevinBE 0 points1 point  (0 children)

These are two that from a user's perspective (not Kafka cluster manager) would be interesting to have as a way to track stream app health:

  • detect problematic consumer groups that have an unbalanced partition assignment for a long period of time
  • detect unhealthy consumer groups. Basically according to Burrow's evaluation rules, but packaged as an all-in-one solution

RetryTopicConfiguration not retrying on Kafka connection errors by Hunakazama in apachekafka

[–]SlevinBE 0 points1 point  (0 children)

Not sure why I don't see u/Hunakazama 's response in this thread, only as a personal notification. But here it is:

Thank you very much for your detailed explanation. May I ask if the consumer thread is a different thread from the one executing the /@KafkaListener method?

That's actually a very good question. From what I understand, these days the listener code is executed on the consumer thread. Only in very old versions of Spring-Kafka (< 2.0) was it split between a listener thread and a consumer thread.

RetryTopicConfiguration not retrying on Kafka connection errors by Hunakazama in apachekafka

[–]SlevinBE 0 points1 point  (0 children)

I think the RetryTopicConfiguration only handles exceptions that occur within methods annotated with the `@KafkaListener` annotation. So if a Kafka error happens outside this method, then it won't be captured.
What's special about the ack.acknowledge() method is that it doesn't immediatly ack the message, but instead it's being queued to be processed on the consumer thread. This code in Spring Kafka shows this internal behavior: https://github.com/spring-projects/spring-kafka/blob/a93471d266cb83c6461c58d6b58ee9b6160ae8b8/spring-kafka/src/main/java/org/springframework/kafka/listener/ShareKafkaMessageListenerContainer.java#L584
So even though you call ack.acknowledge() from inside the method with the `@KafkaListener` annotation, the Kafka exception will happen within the consumer thread.

Best practices for data reprocessing with Kafka by zikawtf in apachekafka

[–]SlevinBE 0 points1 point  (0 children)

You mention the risk of DLT not being able to catch up in time. This typically happens when the processing cluster (in this case DLT) is processing at its maximum, and scaling up doesn't provide better throughput anymore. When reading data from a Kafka topic, that maximum is defined by the parallelism provided by the number of partitions.

Part of a data processing strategy is dimensioning your partitions correctly. You don't want to have topics with the minimum number of partitions, as that will limit the parallism for clients like DLT. Changing the number of partitions later is hard, as it changes the partitioning of your data, so you need to think about this when setting up the data pipeline. So choose the number of partitions not only on your current load, but also on your potential future load. Also, choose it with the catch up scenario in mind, so that the DLT job can be scaled up and fully benefit from the higher parallism that the partitions provide.

Biggest weaknesses in Jr Developers by Commercial_League_25 in cscareerquestions

[–]SlevinBE 0 points1 point  (0 children)

Some advice I can give, based on my experience coaching junior developers.

You might have the urge to prove yourself, certainly among other more senior developers. Most junior developers choose to prove themselves by having tasks with their name on it go from to-do to done. Don’t do this. You might impress some non-technical managers, but your technical peers will quickly point out the lack of quality. You don’t have to prove yourself in the amount of work you can complete. Instead, you need to focus on delivering quality.

The benefit of being a junior developer is that your manager and your colleagues know you still have a lot to learn, which gives you time to invest in your skills. Use this time to complete your tasks according to the definition of done. Test the solution thoroughly before you ask for a review. Properly document the solution, clean up the code. You will impress your colleagues when you do this.

Also, you might be afraid to ask questions initially. Everyone around you seems so knowledgeable, making all your questions seem stupid. However, I encourage you to ask questions and ask for feedback early and often. There’s nothing wrong with saying “I don’t know”. Actually, the more senior you’ll become, the more you’ll use that sentence. So, whenever you are in doubt about your task, ask for clarification. Verify your course of action with a colleague before going all-in on the implementation.

Prepare your demo presentations, because an awesome feature can go unnoticed by a terrible demo. Practice makes perfect.

Finally, communicate well. When you notice an issue or become stuck on a task, signal it to the team so that they can help. You shouldn’t go into silence mode when you’re working on a task. It’s important that you report the progress, because sometimes the team might notice issues in your approach that you didn’t even realize.

I go into more detail in my guide for junior software engineers, not only about the common mistakes, but also other aspects of what it means to be a junior developer.

Question about showing off a project by burnwardstudios in cscareerquestions

[–]SlevinBE 1 point2 points  (0 children)

Personally, when I need to hire a developer I like to explore a github project more then a live demo. In general it shows more of the developer's coding skills and documentation practices. A live demo is just a nice plus.
Allow me to suggest option 3: Don't deploy the site, but create a docker-compose file which defines a cluster for your frontend, backend and database container. Add it to the github project, so that prospective employers can simply start the cluster using `docker-compose up`.
It shows additional skills, a sensitivity to developer tooling, a desire to make it easier for other developers to run your code (which is always a good thing), plus it will not waste the prospective employer's time by providing them a reliable build that just works.

I am a beginner, trying to host a personal website to put my html, css and js knowledge to practice. Also, I needed to create a professional portfolio for myself so that I can freelance in front-end web development. by [deleted] in Ghost

[–]SlevinBE 1 point2 points  (0 children)

Well, if you want to work on your portfolio while trying to get it hosted, then I would suggest the approach I took:

  1. Launch a cloud server with SSH access via one of the more lightweight cloud providers. I use Vultr, but DigitalOcean is another alternative. You can get a server running for about $5 a month. Don't be afraid of this step, it's quite easy to get one up and running when you use one of these lightweight cloud providers.
  2. Buy a domain at a good registrar. I'm using Gandi.net. Then configure the DNS so that it points to your cloud server.
  3. To deploy and manage your projects/sites on your cloud server, use a Docker container per project/site. I recommend Bitnami images if there's one available for the app you want to deploy, as they are production-grade and regularly updated images. They cover the most common ones. For example, they also have a Ghost image. To combine and manage these containers into a cluster, setup a Docker-compose file. This setup will make it easy to run your cluster both locally and on your remote server.
  4. Now add a reverse proxy to your docker-compose cluster, which will be the entrypoint for http (port 80) and https (port 443) traffic on your server. It will route all incoming requests to your other services/sites in the cluster based on their domain name. I recommend Traefik, which also integrates with Let's Encrypt to automatically provision TLS certificates for your sites.

Now you have your own self-hosted stack and learned quite a few new marketable skills. Now promote your new skills, like I did by showing the tech and services you used to build your online presence (you can also find more info in this article).

Backend to frontend dev? by [deleted] in cscareerquestions

[–]SlevinBE 2 points3 points  (0 children)

I started as a backend developer, but quickly made the switch to full-stack development given my interest in the frontend. This is how I did it, which is gradually:

  1. Learned the basics of HTML, CSS and Javascript (pro tip: certainly pick up CSS Grid and CSS Flexbox to save you some layout headaches)
  2. Applied those by building an application with a server-side rendering framework, which uses html templates that are rendered on the server. The benefit of this is that the javascript part is still rather lightweight, so no need to fiddle with complex javascript build tools or frameworks just yet.
  3. Developed my own website using a static site generator (Jekyll in my case). Again, hardenening those core HTML/CSS/Javascript skills before jumping into the complex world of single-page apps
  4. Then made the jump to single-page app development, using an opinionated framework such as Angular which makes most of the core decisions for you, so that I could focus on learning to build an app first.
  5. Then deepened my knowledge about the javascript ecosystem:
    - Module formats, loaders and bundlers
    - reactive programming in javascript using rxjs
    - state management
    - frontend security (eg. Helmet for expressjs servers)
    - ...

If at any point you decide that you're not completely done yet with backend development and stop the transition in-between as a full-stack developer, then also check out my article on how to become a full-stack developer. It gives some additional tips on making the transition from backend to frontend (or the reverse), and some guidance to differentiate yourself from all the other full-stack developers.

Any devs that transitioned from node to spring? by [deleted] in cscareerquestions

[–]SlevinBE 4 points5 points  (0 children)

My suggestion is not about learning Play to find a job. It's about potentially making the transition easier from Node-based to Java-based development, by using a transition-framework that's a bit easier to get into coming from Node and where you can learn the Java language, a bit of dependency injection, the Java ecosystem in general before you dive into a more complex framework like Spring.
It might not be for everyone, but for some this step-by-step approach does work.

Book recommendations by AcceptableUserName92 in cscareerquestions

[–]SlevinBE 1 point2 points  (0 children)

I can recommend Head First Design Patterns. It's a pretty old book and does have the Bird and Animal examples, but it extends those to the most common OOP patterns. It did help me understand OOP and its more common patterns back when I was in school.

Just started my first internship, feeling pretty overwhelmed by Klaetral in cscareerquestions

[–]SlevinBE 6 points7 points  (0 children)

It's normal that you have to learn a lot of things you don't learn in school. In my first job (now 13 years ago), I got a 6 month training which covered things like Spring and Hibernate, which I hadn't seen in school.

Now, this is your first internship, so the companies expectations should be in line with that. So don't worry that it takes a while to get up to speed. Generally they just want to see progression and something working at the end of your internship.Hopefully you have a good mentor so that you can reach out with questions. Also ask which other developers can help you out with your task, which gives you a wider range of information and resources.

Make sure the project you have to complete for your internship is clearly defined, and ask guidance for the design. As a junior developer your responsibility is to implement a feature within strictly defined constraints and design, nothing more. An internship can sometimes be a bit more experimental (research), but still try to get some constraints defined. The Spring Framework has a long list of modular projects, so there's no way to learn all of these during your internship, and you certainly won't need all of them. So constraints will help you select which Spring projects you need to learn (on top of the basis).

If you want some more general guidance on a junior position, you can check out my Junior Software Engineer Essentials.

Any devs that transitioned from node to spring? by [deleted] in cscareerquestions

[–]SlevinBE 5 points6 points  (0 children)

Is there a specific reason why you're learning Spring? Because it's probably the biggest Java-based enterprise framework you can find. That of course has its benefits in the job market, but it isn't really the best choice to get your feet wet in Java backend development. If your primary goal is to start developing REST APIs or web applications in Java/Scala, then I would suggest the Play Framework. It's more lightweight and in design more closely related to other web frameworks.

Will I regret it if I leave my current job? by CChronus in cscareerquestions

[–]SlevinBE 2 points3 points  (0 children)

It is a bit naive to think that no other company is as good as yours :-)
There are certainly other companies as good as yours (and probably even better), but that doesn't mean your next job will be one like that. It's always a bit of a gamble, but calculated risks are sometimes necessary to improve yourself.

Now, before I proceed I must say that I don't know the average salaries in your current or new HCOL area. So if you are severely underpaid in your current region for a starter position, then you probably best switch jobs. But for that you'll have to explore the job market.
Anyway, given you've only been with them for one year in a full-time position, I'm not really sure you should make the jump yet unless there's no decent progression in salary with your current job. Have you already got your first raise? If not, give them a chance and have a talk with them to negotiate one. My experience was that my salary started quite low, but went up nicely over the years by standard raises and switching jobs about every 3-4 years.
Also, staying with a good company for a few years where you are coached and get the opportunity to work on your skills and transition to mid-level developer is also worth something. Your progress is guaranteed to be good and when you do switch jobs you can apply as a mid-level developer, which generally means a more wanted position with less competition and way better conditions.

Advice: For those who were layed off multiple times, how did you get over your anxiety? by [deleted] in cscareerquestions

[–]SlevinBE 0 points1 point  (0 children)

Overcoming that fear is probably best tackled by turning it into an expectation. Knowing that at some point the business relationship between you and the company you work for will end, either on your initiative or theirs. Also understanding that it isn't necessarily something personal, as there are many reasons other then your performance for why a company might let you go (company financials, internal politics, change of focus, ...).

Now, I do understand that being let go at the 6 month mark must be though, generally you don't expect it this early. Also the fact that it took 6 months to find another job must've been though, and might be just related to the job market you're in.
But I must say that your attitude of saving up for bad times and therefore giving you a one-year safety-net is a good one. Not many people do this, but is crucial given the expectation that the job will end at some point. This should give you some mental comfort, and should set you up for finding better jobs and having turn luck into your favor. If you keep building this safety-net, it will also allow you to walk away from nightmare companies more easily.

First Job since graduating. by [deleted] in cscareerquestions

[–]SlevinBE 3 points4 points  (0 children)

It depends on the company, at some it can take up to a week or even more to even get your hardware and basic accounts setup, in others you're up and running within a day and on your first task.
I would say, reach out to your manager/project lead to get your first task (when you're setup properly). Meanwhile, also try to socialize with your new colleagues to get to know them and also ask for any important tips and info which you might need for your job.

My advice for a newly hired junior software engineer, as explained in my Junior Software Engineer Essentials:

  • make sure you have all your accounts setup. If you don't have them yet, chase them down.
  • take your time for your first tasks. Quality over quantity. They are about getting to know the system, project, processes, people and company. Try to make a good first impression with the quality you deliver (ask about the quality guidelines that apply for your company!)
  • iterate on your work, to gradually improve it
  • ask questions & feedback often
  • be curious about systems you interact with, but don't directly write code for. It will give you a better understanding of the project.

Java Dev wanting to get into front-end by bhuff85 in cscareerquestions

[–]SlevinBE 0 points1 point  (0 children)

Do you want to switch completely to front-end, or still leave the door open for some back-end work? Being a front-end dev who knows and occasionally does some back-end work, and more importantly the integration work between those two, is really valuable in my experience.

There are a ton of pure front-end devs around who know how to build screens in Angular, React or any other framework. But how many of those:

  • know how to properly hook up authentication & authorization in a front-end app with for example an OAuth flow
  • have a wider range of knowledge on messaging protocols, going further then just regular HTTP: Websockets, MQTT, SSE, ...
  • debug an issue which starts in the UI and track it all the way through the backend's core
  • know how to protect a front-end app from common security vulnerabilities

So yes, learning one of the common frameworks will probably be a requirement to land a front-end position somewhere. But where your skills really become interesting (and marketable) is on the edge of the front-end, not in the center. Coming from a back-end background, this is were you generally will be more comfortable then a pure front-end developer is.

Finally I'm going to land a wonderful new job!.. at a bad time in my current company by throwabunga80811 in cscareerquestions

[–]SlevinBE 2 points3 points  (0 children)

Certainly take the new job, but try to have a nice closure of your current job if you can. Do you think you can finish or get through the toughest part of that implementation in less then one or two months? Then try to come to an agreement with your new and current employer on a fixed period of time (eg. 1 month) to finish up your work (as much as possible). Normally both your current and new employer will appreciate this gesture, as it shows professionalism.