Integrated energy giant ExxonMobil (XOM -2.78%) did something pretty incredible. It managed to increase its dividend every year for over four decades, despite operating in a highly cyclical industry. If you are looking for a long-term energy holding, that alone should make the stock attractive.

But given its strong performance over the past year, there are risks to consider too in investing in the stock at the moment.

ExxonMobil is built to survive

The oil and natural gas that ExxonMobil extracts from the ground are highly volatile commodities. Prices tend to rise and fall along with economic activity, making the entire energy sector cyclical in nature. The best companies are prepared to operate well throughout the cycle. And given ExxonMobil's incredible dividend history, it has clearly proven it is among the best in the industry.

There are a number of factors that go into that. For starters, ExxonMobil is vertically integrated. Its operations span from the upstream (oil and natural gas production) through the midstream (pipelines) and all the way to the downstream (refining, chemical production, and gas station operations). Each of these industry spaces has different dynamics. For example, midstream assets are generally fee-driven and provide consistent revenue, while refining tends to benefit from low energy prices since oil is a key input. Commodity prices are the biggest driver of financial performance for Exxon, but the other business segments help to mitigate the price swings.

ExxonMobil is also geographically diversified. As commodities, energy prices don't vary much from market to market. However, production costs can vary greatly, and so can actual on-the-ground energy demand. Having a global footprint allows ExxonMobil to focus on the markets where it can maximize its performance.

Lastly, ExxonMobil focuses on maintaining a strong financial core. In this situation that means a rock-solid balance sheet. Basically, when times are bad ExxonMobil adds debt so it can continue to support its business and fund its dividend. When times are good, it pays down debt so it can be ready for the next industry downturn. The chart below comparing Exxon's debt-to-equity ratio and Brent Crude prices, a key oil benchmark, highlights the actions taken to deal with the energy downturn caused by the coronavirus pandemic. It's a plan that has proven reliable for the company and investors.

XOM Debt to Equity Ratio Chart

XOM Debt to Equity Ratio data by YCharts

ExxonMobil generated a good run

From a long-term perspective, conservative investors looking to add an energy stock to their portfolio should probably put ExxonMobil on their shortlist. The roughly-3.5% dividend yield isn't exactly huge historically speaking, but given the long history of dividend growth, it is still pretty attractive. However, there's a caveat, and it shows up in the chart above: Oil prices have been falling of late.

While ExxonMobil's stock price is up around 20% over the past year, it's down about 10% or so from the peaks it saw in early 2023. That's exactly what you'd expect given the oil price declines. 

XOM Chart

XOM data by YCharts

Again, it goes back to the basics of the industry. Although ExxonMobil has a diversified business, energy prices are the main driver of top- and bottom-line performance. With oil prices heading lower of late, so, too, have the company's revenue and earnings. There's not a lot ExxonMobil can do about that, it's just how the industry works.

XOM EPS Diluted (Quarterly) Chart

XOM EPS Diluted (Quarterly) data by YCharts

If energy prices continue to decline, ExxonMobil's business will continue to weaken, and its stock price will probably follow suit. So from a short-term perspective, investors might want to tread with caution. At the very least, if you buy with the intention of holding for the long term, you'll want to be ready for a period of business and stock weakness. If that is a worry for you, you could break your purchase into multiple buckets, buying over time. That will help ensure you don't go all in at the "wrong" time, but will still allow you to build a position in what is a very well-run energy company.

ExxonMobil is a buy, with a warning

When you step back and consider ExxonMobil as a company, it is very well run and the kind of stock most investors will be happy they own over the long term. That said, the energy industry is known for being volatile, and ExxonMobil can't change that.

With energy prices trending lower recently, the company's stock has been less than rewarding. So long as you go in knowing that (and perhaps buy in buckets to adjust for it), ExxonMobil can be a great way to add energy exposure to your portfolio. That will likely remain true even if oil and natural gas prices continue to head lower. But you need to understand the way ExxonMobil deals with such industry weakness to understand why it is so attractive as a long-term holding.