Tales from the jar side: My holiday card, Reactive Spring, and More funny tweets
Debbie Jellinsky: With your looks, your charm ... women must follow you everywhere! Uncle Fester: Store detectives
Welcome to Tales from the jar side, the Kousen IT newsletter, for the week of December 6 - 13, 2020. This week I taught a course on Functional Java on the O’Reilly Learning Platform and a my Managing Your Manager course on the same. I also gave a presentation entitled Your Boss Is Not Your Friend, And Other Keys To A Successful Manager Relationship as part of the Conference in the Cloud. Finally, I taught a private class on Reactive Spring for a client in India.
Our Holiday Card
Before I get to any of that, I thought I’d share this year’s holiday card with you all.
My son is the one in the middle, and this picture looks just like him. Also, the evil mistletoe was my idea.
This is the fifth year we’ve had our card designed by the awesome Len Peralta. His online store can be found here. He is both very fast and very good, which is a great combination. I always like the result, and I’m happy to support him as an online artist. If you wind up contacting him, feel free to mention my name.
Btw, my son agreed with his portrayal.
On a somewhat related note, I still think Addams Family Values is one of the great underrated classics of the 90’s. Technically it’s more of a Thanksgiving movie than an Xmas one (see A Turkey Called Thanksgiving for details), but I like it year round.
Among thousands of great quotes from that move, one that stays with me when I’m writing is from Wednesday (of course):
Your work is puerile and under-dramatized. You lack any sense of structure, character, and the Aristotelian unities.
Yeah, that’s probably true, but I’ll keep writing anyway. At this point, if I didn’t produce a newsletter every week, people would wonder if something was wrong with me.
Wednesday: Do you believe in the existence of evil?
Joel: Have you met my mother?
Gets me every time. :)
Schedulers in Project Reactor
I teach a training course on Reactive Spring on the O’Reilly Learning Platform on a regular basis. It’s only a one-day course, like most courses on that platform, which really means I only have four hours to get through everything. (So yeah, it’s really a half-day course, but they call it one day.) That’s particularly challenging for this course, because reactive concepts are so counter-intuitive. The course has a prerequisite of basic Spring knowledge, but if there’s one thing I know about those courses it’s that you can’t rely on everyone having the prereqs.
This time, however, I was contacted by a third party about a direct training class. I’m not sure how they found me (I kept forgetting to ask), but they were based in India so time zones were going to be an issue. Since their team had a lot of experience with Spring, we agreed to a one-day class (a real one, not just a half day), but to make it easier we decided to do it as two half-days, both in the evening for them and early morning for me.
Time zones. What can you do?
During the initial discussions, the client asked that I include something about schedulers, specifically regarding how to wrap a blocking call in a way that doesn’t interfere too much with the reactive design. I’m rather embarrassed to admit I hadn’t spent much time on that topic, but at least this was an opportunity to fill in that gap.
Spring uses Project Reactor as the library for implementing reactive applications. If you look at the reference manual, The first question in Appendix C discusses that problem specifically. The solution is:
Use a lambda expression to make the blocking call.
Wrap that in a Mono using Mono.fromCallable(…).
Invoke the subscribeOn() method on the Mono with the bounded elastic scheduler.
The idea is to get the system to ensure that each subscription happens on a dedicated, single-threaded worker from the bounded elastic thread pool. This was also consistent with the mechanism shown the Flight of the Flux 3 blog post on the same topic, written by members of the Spring team.
What confused me, however, is that I thought you could just call publishOn(Schedulers.elastic()) before making the blocking call instead, which felt more direct. I couldn’t figure out why one approach was considered better than the other, so I finally asked the question on StackOverflow, figuring somebody would know. I only received one answer which didn’t help. I also asked the question on the Gitter group for Reactor. I got one answer which missed the point, and another that I’m not sure is right.
Still, asking publicly accomplished something: I’m now sure the question wasn’t trivial. I decided go with the recommended way, but ask again later when I understand this stuff better. I have a friend I could ask (Greg Turnquist, who wrote Hacking with Spring Boot 2.3: Reactive Edition) who know this stuff, and he can probably help me, but I didn’t have time to contact him before the class. Besides, that would have required me to let him know that while I bought his book right away, I still haven’t read much of it. Still, I’ll get back to him at some point.
In class, I just discussed the problem and showed both possibilities and told them I wasn’t sure which one was best. I think that’s the best I could do under the circumstances. I hate not knowing the right answer, though. At least it forced me to finally dig into schedulers, so I understand them a lot better now.
It has not escaped my notice that I’m digging into asynchronous programming both with reactive Spring and with Kotlin coroutines. Funny how they’ve come up in my work at the same time.
(That was an asynchronous joke.)
Back in January I made a reactive lightbulb joke on Twitter, but I can’t find it. It was something like this:
Q. How many reactive programmers does it take to change a lightbulb?
A. Only one, but if nobody subscribes to the bulb it stays dark.
If you do reactive programming, I can assure you that joke is eventually funny.
(That was another asynchronous joke. Sorry. #notsorry)
The class was intense, but went well.
Marketing Works
Hey, early in the week somebody at O’Reilly Media (Hi again Suzanne!) tweeted this:
Aside from the fact that the class was actually four hours rather than three, it was great to see this. We had a sizable group, which was great.
In fact, the only downside was that I still haven’t gotten my revisions done to the point that my book is available for purchase, even in beta form. Hopefully that will happen this week.
I should also mention that my page at O’Reilly Media now includes a selection of my videos, and the training courses are now in chronological order. Sweet.
I Really Did Think I Was Done
I have a few more classes this week, and then I was supposed to be finished for the year. And yet:
I was contacted by one of my clients who had year-end money to spend, asking for a two-day Spring course. I discussed it with my wife, who knows how much I was looking forward to an actual (more or less) vacation the last two weeks of the year.
I asked the client what rate they were offering. Mentally I had already decided that if it was X, I would say no, and if it was Y, I would say yes.
Sure enough (I’m sure you can see where this is heading), without any information about my boundaries, they somehow managed to offer (X + Y)/2, splitting the difference down the middle.
I gave up and said yes. I don’t have a confirmation yet, but it looks like I’ll have another class the week of Dec 21. Sigh. It’s hard to turn down business when you’re an independent, especially during a global pandemic, but at some point I’m going to need to factor in the therapy bills from pushing myself too far.
(Not that there’s anything wrong with therapy, but that’s a topic for another day.)
Funny Tweets
To finish up, here are some amusing tweets this week:
That hits way too close to home.
It’s the holiday season, so:
Tired of proving you’re a person?
Yeah, good luck with that. This one is a geek joke, but some people will get it:
I am often most productive when I’m trying to avoid other work. For example, I now have a keyboard shortcut to produce \🦈
Finally, an oldie but a goodie:
Last week:
Functional Java, on the O’Reilly Learning Platform
Your Boss Is Not Your Friend, at the Conference In The Cloud
Managing Your Manager, on the O’Reilly Learning Platform
Reactive Spring, private class
This week:
Next Generation Java Testing with JUnit 5, on the O’Reilly Learning Platform
JUnit 5 and Mockito, an NFJS Virtual Workshop
What’s New In Java, on the O’Reilly Learning Platform
Spring MVC Fundamentals, same